Answered step by step
Verified Expert Solution
Link Copied!

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 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).
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago