I need to create a program which asks a user to input a list of names and each name should be added to an array and the user can only input 10 names maximum and if they try to input more a message needs to come up and say that they have already have ten names and then output those ten names. I am struggling with the outputs
let inputArray = [];
let size = 11;
for(let i = 0; i < size; i++){
if (i < size) {
inputArray[i] = prompt("Please enter the name of 10 people
you would like to invite to a party"
+ (i+1));
} else if (i = 11) {
console.log("You have already invited 10 people");
}
}
console.log(inputArray);
2
Answers
try this
Try this out and see if it works for you.