Skip to content

Instantly share code, notes, and snippets.

@okisanjp
Last active December 14, 2016 03:38
Show Gist options
  • Save okisanjp/fd1907e2a78de4e63954b2dbafca98cb to your computer and use it in GitHub Desktop.
Save okisanjp/fd1907e2a78de4e63954b2dbafca98cb to your computer and use it in GitHub Desktop.
js.fizzbuzz.practice
console.clear();
for(var i = 1; i <= 100; i++){
console.log(
// confusing use of '!'
!(i % 15) && 'FizzBuzz' ||
!(i % 5) && 'Buzz' ||
!(i % 3) && 'Fizz' ||
i
);
}
console.clear();
for(var i = 1; i <= 100; i++){
console.log(
(i % 15 === 0 && 'FizzBuzz') ||
(i % 5 === 0 && 'Buzz') ||
(i % 3 === 0 && 'Fizz') ||
i
);
}
console.clear();
for(var i = 1; i <= 100; i++){
console.log(
// (笑)
!Boolean(i % 15) && 'FizzBuzz' ||
!Boolean(i % 5) && 'Buzz' ||
!Boolean(i % 3) && 'Fizz' ||
i
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment