forked from learn-co-students/js-deli-counter-js-apply-000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (20 loc) · 763 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var katzDeliLine = [];
function takeANumber(line, name) {
line.push(name);
return "Welcome, " + name + ". You are number " + line.length + " in line.";
}
function nowServing(katzDeliLine) { // does this function return a single person? or the string "currently serving"?
if (katzDeliLine.length === 0) {
return 'There is nobody waiting to be served!';
}
return 'Currently serving ' + katzDeliLine.shift() + '.';
}
function currentLine(katzDeliLine) {
if (katzDeliLine.length === 0) return "The line is currently empty.";
var deliLine = [];
for (var i = 0; i < katzDeliLine.length; i++) {
var num = i + 1;
deliLine.push(' ' + num + '. ' + katzDeliLine[i]);
}
return 'The line is currently:' + deliLine.join(",");
}