Trying to have a user input a number and if they type in a string I would like to prompt them to enter a number. Seems like I got that part right but how can I get the second prompt to keep popping up until the user enters a an actual number. As of now, once the user enters a string again nothing runs after that. Would appreciate any kind of suggestions.
Here is the code:
function enterNumber(n) {
n = parseInt(prompt("Please enter a number: "));
if (isNaN(n)) {
n = parseInt(prompt("You did not enter a number. Please enter a number: "));
for(var i = 1; i <= n; i++) {
if (i % 15 === 0) {
document.write("Fizz Buzz" + "<br>");
continue;
}
else if (i % 3 === 0){
document.write("Fizz" + "<br>");
continue;
} else if (i % 5 === 0) {
document.write("Buzz" + "<br>");
continue;
}
document.write(i + "<br>");
}
}
};
enterNumber();