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 and runner both set to false.
b Create a loser variable set to an empty string.
b Create two new promises called runnerGo and runnerGo
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 runner in
runner or runner in runner then resolves the value true.
iii. You may chose the timeout lengths as long as they are under seconds
c Return an array with the following values:
i The result of runnerGo you will need to await this
ii The result of runnerGo 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 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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
