Last active
October 26, 2019 12:53
-
-
Save KamahGit/e29501e5a0a2351bc2232b52a9d20d95 to your computer and use it in GitHub Desktop.
Fizz Buzz - my first gist!
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 fizzBuzzFunc = (n)=>{ | |
for(let i=1; i<=n; i++){ | |
let fizz, buzz, fizzBuzz; | |
fizz = (i%3===0); | |
buzz = (i%5===0); | |
fizzBuzz = (fizz && buzz); | |
fizzBuzz? console.log('FizzBuzz'): fizz? console.log('fizz'):buzz? console.log('Buzz'): console.log(i); | |
}}; | |
fizzBuzzFunc(20); | |
Output-> | |
1 | |
2 | |
fizz | |
4 | |
Buzz | |
fizz | |
7 | |
8 | |
fizz | |
Buzz | |
11 | |
fizz | |
13 | |
14 | |
FizzBuzz | |
16 | |
17 | |
fizz | |
19 | |
Buzz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm going to ace the interview! LOL!