Last active
September 14, 2017 13:33
-
-
Save sharpred/1217327d09c52166019b3dbf227fc313 to your computer and use it in GitHub Desktop.
calc fizzbuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fizzBuzz = x => { | |
let test1 = x % 3 === 0 ? 1 : 0; | |
let test2 = x % 5 === 0 ? 2 : 0; | |
return test1 | test2; | |
}; | |
const printFizzBuzz = (item, val) => { | |
let x = val + 1; | |
switch (fizzBuzz(x)) { | |
case 1: | |
console.log("Fizz"); | |
break; | |
case 2: | |
console.log("Buzz"); | |
break; | |
case 3: | |
console.log("FizzBuzz"); | |
break; | |
default: | |
console.log(x); | |
break; | |
} | |
} | |
Array(100).fill("").forEach(printFizzBuzz); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment