i m struggling with this. How to "if not an integer , alert and repeat prompt" ? I have the alert working , but i cant make it to prompt again.
The same with isNAN which is not working at all!
Thank you
$(document).ready(function () {
var fizzBuzz = function () {
var userNum = prompt('Enter a number!');
var convertNum = +userNum;
for (var i = 1; i <= convertNum; i++) {
if (i % 15 === 0) {
$('ul').append('<li>' + "fizzbuzz" + '</li>');
} else if (i % 3 === 0) {
$('ul').append('<li>' + "fizz" + '</li>');
} else if (i % 5 === 0) {
$('ul').append('<li>' + "buzz" + '</li>');
} else if (isNaN(userNum)) {
alert("Input is not a number");
} else if (convertNum % 1 !== 0) {
alert('Please enter a whole number');
return false;
} else {
$('ul').append('<li>' + i + '</li>');
}
}
};
fizzBuzz();
});