Created
March 6, 2017 04:52
-
-
Save itzsaga/a085e36e4fa7c7b5f081fd9879e7ad11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var katzDeliLine = []; | |
| function currentLine(x) { | |
| var line = [] | |
| if (x.length === 0) { | |
| return "The line is currently empty." | |
| } else { | |
| for(var i = 0; i < x.length; i++) { | |
| line += (i + 1) + ". " + x[i] + ", " | |
| } | |
| line = line.slice(0, line.length-2) | |
| return "The line is currently: " + line | |
| } | |
| } | |
| function takeANumber(katzDeliLine, name) { | |
| katzDeliLine.push(name) | |
| return "Welcome, " + name + ". You are number " + katzDeliLine.length + " in line." | |
| } | |
| function nowServing(x) { | |
| if (x.length === 0) { | |
| return "There is nobody waiting to be served!" | |
| } else { | |
| var name = x[0]; | |
| x.splice(0, 1); | |
| return "Currently serving " + name + "."; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment