Skip to content

Instantly share code, notes, and snippets.

@astout
Created January 10, 2018 17:02
Show Gist options
  • Save astout/c6fc5cdbbfb3c53c91ce968d9c99ae14 to your computer and use it in GitHub Desktop.
Save astout/c6fc5cdbbfb3c53c91ce968d9c99ae14 to your computer and use it in GitHub Desktop.
FizzBuzz Interview Practice
function fizzbuzz(fizz = 3, buzz = 5, max = 100) {
for (let i = 0; i <= max; i += 1) {
if (i % fizz === 0 && i % buzz === 0) {
console.log('fizzbuzz');
} else if (i % fizz === 0) {
console.log('fizz');
} else if (i % buzz === 0) {
console.log('buzz');
} else {
console.log(i);
}
}
}
fizzbuzz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment