Sobes.tech
Back to questions
Middle+
8

const doSomething = (ms) => { return new Promise((resolve, reject) => { setTimeout(() => { if (Math.random() <= 0.5) { reject("error"); } else { resolve(ms); } }, ms); }); }; const getDelay = () => { let rand = 1000 + Math.random() * 2000; return Math.floor(rand); }; const p1 = doSomething(getDelay()); const p2 = doSomething(getDelay()); const p3 = doSomething(getDelay()); const p4 = doSomething(getDelay());

Companies where asked
IT OneIT One