Last active
July 23, 2021 16:22
-
-
Save vovk1805/74a0183b12fd449b31c4b4aedbba674b to your computer and use it in GitHub Desktop.
Async forEach JS
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 promise = new Promise((res) => res('lol')); | |
const arr = [1, 2, 3, 4, 5]; | |
const result = []; | |
arr.forEach(async (el) => { | |
const res = await promise; | |
if (res === 'lol') { | |
result.push(el); | |
} | |
}); | |
// тут би мав бути масив з числами | |
console.log('result ↓↓↓↓↓↓↓↓↓↓↓↓↓'); | |
console.dir(result, { depth: 10000, colors: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment