Open this example in the interactive library
Source code
const results = [];
for (const n of [1, 2, 3]) results.push(await Promise.resolve(n * 2));
console.log(results);
Sample output
[ 2, 4, 6 ]

Process tasks sequentially. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const results = [];
for (const n of [1, 2, 3]) results.push(await Promise.resolve(n * 2));
console.log(results);
[ 2, 4, 6 ]