JavaScript Asynchronous: Exercises, Practice, Solutions
JavaScript Asynchronous Programming [ 9 exercises with solution ]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a JavaScript function that takes a callback and invokes it after a delay of 2 second.
2. Write a JavaScript program that converts a callback-based function to a Promise-based function.
3. Write a JavaScript a function that makes an HTTP GET request and returns a Promise that resolves with the response data.
4. Write a JavaScript function that takes an array of URLs and downloads the contents of each URL in parallel using Promises.
5. Write a JavaScript program that implements a function that performs a series of asynchronous operations in sequence using Promises and 'async/await'.
6. Write a JavaScript function that fetches data from multiple APIs concurrently and returns a combined result using Promises and 'Promise.all()'.
7. Write a JavaScript function that fetches data from an API and retries the request a specified number of times if it fails.
8. Write a JavaScript program to implement a function that executes a given function repeatedly at a fixed interval using 'setInterval()'.
9. Write a JavaScript function that fetches data from an API and cancels the request if it takes longer than a specified time.
More to Come !
* To run the code mouse over on Result panel and click on 'RERUN' button.*
Live Demo:
See the Pen javascript-common-editor by w3resource (@w3resource) on CodePen.
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/javascript-exercises/asynchronous/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics