forked from learn-co-students/js-deli-counter-js-apply-000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (26 loc) · 710 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
29
30
31
32
33
function takeANumber(line, name) {
line.push(name);
return "Welcome, " + name + "." + " You are number " + (line.indexOf(name) + 1) + " in line.";
}
function nowServing(line) {
if (line.length === 0) {
return "There is nobody waiting to be served!";
} else {
var first = line[0];
line.shift(first);
return "Currently serving " + first + ".";
}
}
function currentLine(line) {
var lineString = "The line is currently:";
if (line.length === 0) {
return "The line is currently empty.";
}
for (var i = 0; i < line.length; i++) {
lineString += " " + (i + 1) + ". " + line[i];
if (i !== line.length - 1) {
lineString += ",";
}
}
return lineString;
}