Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Project JavaScript L2 Asynchronous Programing

Topics: The async Keyword, Writing async Functions, Handling Dependent Promises, Handling Errors, Handling Independent Promises, Await Promise.all()

Project Title: Smart House

  1. Create a html file with your name like john.html
  2. Add current code to that file:
<!DOCTYPE html>
      // your code here
  1. When user press energySaving button of smart house remote control, we call these 3 functions sequentially:

    • smartTurnOffLight()
    • smartTurnOffAirConditioner()
    • smartTurnOffWashingMachine()
  2. Create async function energySaving() and then call above 3 functions sequentially.

  3. function smartTurnOffLight is async and check a current time, if it is between 7am to 6pm it return TurnOffLight Done string after 3 seconds else throw exception Failed to TurnOffLight after 2 seconds.

  4. function smartTurnOffAirConditioner is async and check a current date, if it is summer it return TurnOffAirConditioner Done string after 1 seconds else throw exception Failed to TurnOffAirConditioner after 3 seconds.

  5. function smartTurnOffWashingMachine is async and check a current time, if it is between 2pm to 5pm it return TurnOffWashingMachine Done string after 1.5 seconds else throw exception Failed to TurnOffWashingMachine after 0.5 seconds.

  6. In energySaving function if all functions run successfully console.log("Energy Saving is Off") else show errors.

  7. create energySavingConcurrent function and run all 3 functions concurrently. Log the result all functions into console.

Want to get reviewed?

Send Pull Request. Check how to deliver your code:

Need help?

Download Learn JavaScript eBook from

You can’t perform that action at this time.