+7

AJAX - Promise.all method - unexpected output dilemma.

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 Answer

+8

I 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

+6

DPP Please donot spam. https://www.sololearn.com/discuss/1316935/?ref=app

-2