Skip to content

Instantly share code, notes, and snippets.

@philmander
Created January 8, 2019 16:27
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 philmander/3fd957de468fa3454b74d62d9f9cd623 to your computer and use it in GitHub Desktop.
Save philmander/3fd957de468fa3454b74d62d9f9cd623 to your computer and use it in GitHub Desktop.
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