My question is about why there are two expected outputs from sololearn challenges in this chunk of ajax code but when I test in the debugger this gives me only [foo, car] as output? const a = new Promise((res, rej) => { //n1 setTimeout(() => res('foo'), 300); }); const b = new Promise((res, rej) => { setInterval(() => rej('bar'), 100); res('car'); }); Promise.all([a, b]).then((race) => { console.log(race); }).catch((crash) => { console.log(crash); }); Right answers: [foo, car] ['bar', 'car'] - why this?
4/12/2019 8:13:11 AM
Luis Febro π§π·3 Answers
New AnswerI have not much idea about js promises but i can help you with this link.. https://stackoverflow.com/questions/55979096/ajax-promise-all-method-unexpected-output-dilemma
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message