Created
September 24, 2019 17:12
-
-
Save JO3-W3B-D3V/f6585df50e06c2f55449edad26f47b32 to your computer and use it in GitHub Desktop.
This is a concise fizzbuzz solution.
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
/** | |
* This is just an example of how concise the FizzBuzz solution can be. | |
* This may not be the most efficient or elegant solution in the world, but eh, it's a bit of fun! :) | |
*/ | |
// Just off load the logic to a method for the sake of ease. | |
// It could be a one line solution, but it's a little harder to read that way. | |
const print = i => (i % 3 == 0 ? 'Fizz' : '') + (i % 5 == 0 ? 'Buzz' : '') || i; | |
// Now to iterate over an array with 100 elments & print the solution. | |
Array.from(Array(100).keys()).map(i => ++i).forEach(i => console.log(print(i))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment