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

JavaScript Coding Exercise 28

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 process(array) {
14
15array.forEach(async (item) => {
16
17await delayedLog(item);
18});
19
20console.log("Process completed!");
21}
22
23process([1, 2, 3, 5]);

Choose the correct output:

A
1 2 3 5 and Process completed!
B
5 5 5 5 and Process completed!
C
Process completed! and 5 5 5 5
D
Process completed! and 1 2 3 5

Advertisement

Responsive Ad
27of86