Skip to content

Instantly share code, notes, and snippets.

@tuckcodes
Created December 22, 2018 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuckcodes/105a9413aca21171b70a7e67789809c1 to your computer and use it in GitHub Desktop.
Save tuckcodes/105a9413aca21171b70a7e67789809c1 to your computer and use it in GitHub Desktop.
Traditional fizz buzz but with a switch statement for fun
// FizzBuzz
// Good ol'fashioned fizz buzz
// Decided to use a switch statement to mix it up a little
for (let numStart = 0; numStart<100; numStart++) {
switch (true) {
case ((numStart>0) && (numStart%3 == 0)):
console.log("Fizz");
break;
case ((numStart>0) && (numStart%5 == 0)):
console.log("Buzz");
break;
default:
console.log(numStart);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment