SHARE
TWEET

Untitled

a guest Feb 14th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const func = (num) => new Promise(res => {
  2.     function log (number) {
  3.         const resultArray = []
  4.         for (let i = number; i > 0; --i) {
  5.             if (i % 3 === 0 && i % 5 === 0) {
  6.                 resultArray.push('awesome'.repeat(i))
  7.             } else if (i % 3 === 0) {
  8.                 resultArray.push('fizz'.repeat(i))
  9.             } else if (i % 5 === 0) {
  10.                 resultArray.push('buzz'.repeat(i))
  11.             } else {
  12.                 resultArray.push(i.toString().repeat(i))
  13.             }
  14.         }
  15.    
  16.         return resultArray.join('')
  17.     }
  18.  
  19.     res(log(num))
  20. })
  21.  
  22. const asyncFunc = async () => {
  23.     const result1 = await func(5)
  24.     const result2 = await func(3)
  25.     console.log(result1, result2)
  26. }
  27.  
  28. asyncFunc()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top