Exercise 13.3

This commit is contained in:
Karan 2021-11-24 22:15:24 +05:30 committed by GitHub
parent 1ebd51c38c
commit 8bccfa9c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

17
Chapter 13/Exercise 13.3 Normal file
View File

@ -0,0 +1,17 @@
let cnt = 0;
function outputTime(val) {
return new Promise(resolve => {
setTimeout(() => {
cnt++;
resolve(`x value ${val} counter:${cnt}`);
}, 1000);
});
}
async function aCall(val) {
console.log(`ready ${val} counter:${cnt}`);
const res = await outputTime(val);
console.log(res);
}
for (let x = 1; x < 4; x++) {
aCall(x);
}