Skip to content

Instantly share code, notes, and snippets.

@KamahGit
Last active October 26, 2019 12:53
Show Gist options
  • Save KamahGit/e29501e5a0a2351bc2232b52a9d20d95 to your computer and use it in GitHub Desktop.
Save KamahGit/e29501e5a0a2351bc2232b52a9d20d95 to your computer and use it in GitHub Desktop.
Fizz Buzz - my first gist!
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
@KamahGit
Copy link
Author

I'm going to ace the interview! LOL!

@aiden2480
Copy link

Uncaught ReferenceError: n is not defined

@KamahGit
Copy link
Author

Thanks @aiden2480 - I was using it in a function -updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment