Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const func = (num) => new Promise(res => {
- function log (number) {
- const resultArray = []
- for (let i = number; i > 0; --i) {
- if (i % 3 === 0 && i % 5 === 0) {
- resultArray.push('awesome'.repeat(i))
- } else if (i % 3 === 0) {
- resultArray.push('fizz'.repeat(i))
- } else if (i % 5 === 0) {
- resultArray.push('buzz'.repeat(i))
- } else {
- resultArray.push(i.toString().repeat(i))
- }
- }
- return resultArray.join('')
- }
- res(log(num))
- })
- const asyncFunc = async () => {
- const result1 = await func(5)
- const result2 = await func(3)
- console.log(result1, result2)
- }
- asyncFunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement