JS Coding Questions Logo
JS Coding Questions
#27🎯 Exercise💻 Code

JavaScript Coding Exercise 27

Advertisement

728x90
javascript
1function delay() {
2
3return new Promise(resolve => setTimeout(resolve, 2000));
4}
5
6async function delayedLog(item) {
7
8await delay();
9
10console.log(item);
11}
12
13async function processArray(array) {
14
15array.forEach(item => {
16
17await delayedLog(item);
18})
19}
20
21processArray([1, 2, 3, 4]);

Choose the correct output:

A
SyntaxError
B
1, 2, 3, 4
C
4, 4, 4, 4
D
4, 3, 2, 1

Advertisement

Responsive Ad
26of86