Skip to content

Instantly share code, notes, and snippets.

@newtomsoft
Created June 28, 2020 14:26
Show Gist options
  • Select an option

  • Save newtomsoft/859b4f29656299f6eb20864599f4f549 to your computer and use it in GitHub Desktop.

Select an option

Save newtomsoft/859b4f29656299f6eb20864599f4f549 to your computer and use it in GitHub Desktop.
FizzBuzz in JS
function FizzBuzz() {
for (let i = 1; i <= 100; i++) {
if ((i % 3 === 0) && (i % 5 === 0)) {
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Fizz");
} else if (i % 5 === 0) {
console.log("Buzz");
} else {
console.log(i);
}
}
}
function FizzBuzz2() {
for (let i = 1; i <= 100; i++)
if ((i % 3 === 0) && (i % 5 === 0)) console.log("FizzBuzz");
else if (i % 3 === 0) console.log("Fizz");
else if (i % 5 === 0) console.log("Buzz");
else console.log(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment