Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started