Skip to content

Instantly share code, notes, and snippets.

@Megafry
Last active March 21, 2020 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Megafry/ea39cfd7752888c6458571e544b58fdc to your computer and use it in GitHub Desktop.
Save Megafry/ea39cfd7752888c6458571e544b58fdc to your computer and use it in GitHub Desktop.
FizzBuzz challenge
const numberOfLoops = 100
const numbersToReplace = [ [3,'Fizz'], [5,'Buzz'] ]
for(i=1;i<=numberOfLoops;i++){
r = numbersToReplace.filter( replacement => !(i % replacement[0]))
console.log( r.length ? r.map(result => result[1]).join('') : i )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment