13 lines
390 B
JavaScript
13 lines
390 B
JavaScript
let number = parseInt(prompt('FizzBuzz: Input a total number'));
|
|
if (isNaN(number)) {
|
|
alert("Not a number, refreshing");
|
|
location.reload();
|
|
} else {
|
|
for (let i = 1; i <= number; i++) {
|
|
output = "";
|
|
if (i % 3 === 0) (output += "Fizz");
|
|
if (i % 5 === 0) (output += "Buzz");
|
|
if (!output) (output = i.toString());
|
|
console.log(output);
|
|
}
|
|
} |