Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (30 points). You are given a set of asynchronous, non-blocking tasks. Each task will call a supplied callback when it finishes executing. You are

image text in transcribed
1. (30 points). You are given a set of asynchronous, non-blocking tasks. Each task will call a supplied callback when it finishes executing. You are to write a function, called roundAndRound, that takes as arguments the set of tasks, an integer 'rep', and two callbacks. Review the code below: let tasks = [taska, taskb, taskc, taskD]; let perRound = (i) => I console.log('Done with round: ' + i); }; let allDone = ( ) => { console.log('Done with everything'); roundAndRound (tasks, 7, perRound, allDone); You need to execute every task 'rep' number of times. So for the example above, every task is going to be executed 7 times. But, we want to execute the tasks is rounds, i.e. run every task once, when they are all done, then run all of the tasks again, over and over. At the end of each round we call the first callback, and the end of all of the runs we call the second. Said in pseudocode: for i - i to rep: start all tasks wait for all tasks to complete call first callback call second callback Obviously, just translating the pseudocode to Javascript is really not going to work. Implement roundAndRound below

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

In terms of basic handling, what is the role of a unit load?

Answered: 1 week ago