- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncSpr.js
More file actions
Latest commit
20 lines (18 loc) · 449 Bytes
/
Copy pathAsyncSpr.js
File metadata and controls
20 lines (18 loc) · 449 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
constrndmdly=(maxtime)=>{
letdly=0+Math.random()*maxtime
returnMath.ceil(dly*1000)
}
asyncfunctionplaceOrder(){
returnawaitnewPromise((resolve,reject)=>{
setTimeout(()=>{
resolve("Your order has been confirmed")
},rndmdly(10));
})
}
(functionmain(){
placeOrder().then(result=>{
console.log(result);
}).catch(err=>{
console.error(err);
})
})()