Refer to the code below (corrected to use a template literal on line 08):
01 let car1 = new Promise((_, reject) =>
02 setTimeout(reject, 2000, "Car 1 crashed in")
03 );
04 let car2 = new Promise(resolve =>
05 setTimeout(resolve, 1500, "Car 2 completed")
06 );
07 let car3 = new Promise(resolve =>
08 setTimeout(resolve, 3000, "Car 3 completed")
09 );
10
11 Promise.race([car1, car2, car3])
12 .then(value => {
13 let result = `${value} the race.`;
14 })
15 .catch(err => {
16 console.log("Race is cancelled.", err);
17 });
What is the value of result when Promise.race executes?
Refer to the code below:
01 let first = 'Who';
02 let second = 'What';
03 try {
04 try {
05 throw new Error('Sad trombone');
06 } catch (err) {
07 first = 'Why';
08 throw err;
09 } finally {
10 second = 'When';
11 }
12 } catch (err) {
13 second = 'Where';
14 }
What are the values for first and second once the code executes?
A developer wants to catch any error that countSheep() may throw and pass it to handleError().
Which implementation is correct?
for (let number = 2; number <= 5; number += 1) {
// faster code statement here
}
Which statement meets the requirements to log an error when the Boolean statement evaluates to false?
A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate().
How can the developer import and use printDate()?