Created
January 8, 2019 16:27
-
-
Save philmander/3fd957de468fa3454b74d62d9f9cd623 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { getRandomWord } = require('word-maker'); | |
const getFizzBuzz = n => `${n % 3 === 0 ? 'Fizz' : ''}${n % 5 === 0 ? 'Buzz' : ''}`; | |
async function getResults() { | |
const promises = Array(100).fill().map(async (v, i) => { | |
i++; | |
try { | |
return `${i}: ${getFizzBuzz(i) || await getRandomWord({ withErrors: true })}`; | |
} catch (err) { | |
return `${i}: Doh!`; | |
} | |
}); | |
return await Promise.all(promises); | |
} | |
getResults().then(results => { console.log(results.join('\n'));}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment