Skip to content

Instantly share code, notes, and snippets.

@giovanniantonaccio
Created September 20, 2019 14:04
Show Gist options
  • Save giovanniantonaccio/f348a0691f77106c0e9cbd761483e0e2 to your computer and use it in GitHub Desktop.
Save giovanniantonaccio/f348a0691f77106c0e9cbd761483e0e2 to your computer and use it in GitHub Desktop.
FizzBuzz algorithm
/**
* FizzBuzz algorithm
*/
function checkMultiples(n) {
let result = "";
result = n % 3 === 0 ? "Fizz" : result;
result = n % 5 === 0 ? result + "Buzz" : result;
return result !== "" ? result : n;
}
for (i = 1; i <= 100; i++) {
console.log(checkMultiples(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment