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
42 lines (27 loc) · 890 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
34
35
36
37
38
39
40
41
42
var katzDeliLine = [];
const takeANumber = (katzDeliLine, newCustomerName) => {
katzDeliLine.push(newCustomerName);
let position = katzDeliLine.length;
return `Welcome, ${newCustomerName}. You are number ${position} in line.`;
}
const nowServing = (katzDeliLine) => {
let firstPerson = katzDeliLine[0];
if(firstPerson === undefined){
return 'There is nobody waiting to be served!'
} else {
katzDeliLine.shift();
return `Currently serving ${firstPerson}.`;
}
}
const currentLine = (katzDeliLine) => {
let lineStatus = 'The line is currently: ';
if(katzDeliLine.length === 0){
return 'The line is currently empty.';
}
for(let i = 0; i < katzDeliLine.length; i++){
let currentElem = katzDeliLine[i];
lineStatus += `${i+1}. ${currentElem}, `
}
let cleanLineStatus = lineStatus.slice(0,-2);
return cleanLineStatus;
}