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
35 lines (25 loc) · 785 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
let katzDeliLine = [];
function takeANumber(katzDeliLine, newCustomer) {
katzDeliLine.push(newCustomer);
return `Welcome, ${newCustomer}. You are number ${katzDeliLine.length} in line.`;
}
function nowServing(katzDeliLine) {
if (katzDeliLine.length === 0) {
return 'There is nobody waiting to be served!';
} else {
let servingCustomer = katzDeliLine[0];
katzDeliLine.splice(0, 1);
return `Currently serving ${servingCustomer}.`;
}
}
function currentLine(katzDeliLine) {
if (katzDeliLine.length === 0) {
return 'The line is currently empty.';
} else {
let msg = 'The line is currently: ';
for(let i=0; i<katzDeliLine.length; i++) {
msg += `${i + 1}. ${katzDeliLine[i]}, `;
}
return msg.slice(0, -2);
}
}