Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #2115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Done #2115

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function takeANumber(deliLine, name) {
var spotInLine = deliLine.length + 1;

//this denotes the number given to a person, as opposed to the number in the array

deliLine.push(name);

//adding to the length & adding the person's name

return "Welcome, " + name + ". You are number " + spotInLine + " in line.";
}

function nowServing(katzDeliLine) {
var personInLine = katzDeliLine[0];

//equal to the person at index 0 (first person in line)

if(katzDeliLine.length === 0)
return "There is nobody waiting to be served!";

katzDeliLine.shift();
//removes the first person in line

return "Currently serving " + personInLine + ".";
}

function currentLine(people) {
if(people.length === 0)
return "The line is currently empty.";

var line = ""

//line is a string, so "line = line ..." will come out as a sentence

for(let i = 0; i < people.length; i++) {
line += (i + 1) + ". " + people[i];

//accessing the person at certain index in the array. loop stops and adds period when done

if(i != people.length - 1) {
line = line + ", ";

//adds comma when loop is not done (not at last index in array)

}
}
return "The line is currently: " + line;


}