- Ask the user to input names of people they would like to invite to a dinner party.
- Each name should be added to an array.
- The user can only invite a maximum of ten people. If they try to add more than 10 names, the program should state, “You have already added 10 people to your guest list.”
- The program should then output the list.
I am trying to solve this task, I am not sure if I am doing it properly. I am a beginner so I will appreciate any help or hints.
{
let list = [];
list.length = 10
while(true){
let input = prompt("Add a guest");
if(input <= 10 || input == null){
break; //arr.slice(0,10)
}
list.push(String(input));
console.log(list);
}
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/9yCVw1N
Comments
Post a Comment