while (true) {
if (memberName == subMemberGroup.indexOf("Leonardo", "Catherine", "Luther", "Bruce", "Amy") !== -1) {
console.log("\nMember's name exists in database. Please enter a new name.");
var memberName = input.question("Please enter member's name: ");
} else break;
}
I am trying to loop through to see if "memberName" that the user has input matches any of the following strings in the "subMemberGroup" array.
However, when I tried using while loop, it keeps saying that Member's name exist even thought the "memberName" that the user input does not match the strings in "subMemberGroup" array. I tried using if statement with a break but it still does not work.
The reason why I used while loop is because I want my code to re-prompt the user the enter a new name if the "memberName" matches the strings in "subMemberGroup" array.