Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created March 6, 2017 04:52
Show Gist options
  • Select an option

  • Save itzsaga/a085e36e4fa7c7b5f081fd9879e7ad11 to your computer and use it in GitHub Desktop.

Select an option

Save itzsaga/a085e36e4fa7c7b5f081fd9879e7ad11 to your computer and use it in GitHub Desktop.
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