JavaScript Tasks: setTimeout, setInterval, and
Promises
Part 1: setTimeout and setInterval Tasks
1 Warning Message: When a user clicks a button, use setTimeout() to display a warning
message after 5 seconds.
2 Advertisement Delay: When a website opens, use setTimeout() to show an advertisement after
10 seconds.
3 Live Clock: Use setInterval() to update and display the current time every 1 second on a
webpage.
4 Notification Sound: Use setInterval() to play a notification sound every 10 minutes (600000
milliseconds).
5 Countdown Timer: Use setInterval() to decrease a counter every second until it reaches zero,
then stop the timer.
Part 2: JavaScript Promise Tasks
1 Task 1: Login Verification
Create a Promise that checks username and password. Resolve if valid, reject if invalid.
2 Task 2: Online Order Status
Create a Promise that checks item stock. Resolve with 'Order confirmed' if available, reject with
'Out of stock' if not.
3 Task 3: OTP Verification
Create a Promise that sends an OTP. Resolve if OTP is correct, reject if incorrect or expired.
4 Task 4: Age Validation
Create a Promise that checks user age. Resolve if age is 18 or above, reject if below 18.