Question: Create a new async function that should do the following: a . Create two new variables called runner 1 and runner 2 , both set

Create a new async function that should do the following:
a. Create two new variables called runner 1 and runner 2, both set to false.
b. Create a loser variable set to an empty string.
b. Create two new promises called runner1Go and runner2Go.
i. Each promise should have a resolve parameter.
ii. Each promise should also use the setTimeout() method to set a timeout for an anonymous function that sets the loser value to runner1 in
runner 1Go, or runner 2 in runner 2Go, then resolves the value true.
iii. You may chose the timeout lengths as long as they are under 10000(10 seconds).
c. Return an array with the following values:
i. The result of runner1Go (you will need to await this)
ii. The result of runner2Go (you will also need to await this)
iii. The value of loser (this should come last in the array)
Call the async function from step 2, and use a then clause to run an anonymous function afterwards. The anonymous function should take one
parameter (which will be the return value of the async function). The function should log the loser to the console. (Hint: This is the last value in the array
that you returned from the async function).
 Create a new async function that should do the following: a.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!