Complete the code to schedule a function to run after 2 seconds.
setTimeout(() => { console.log('Hello!'); }, [1]);The setTimeout delay is in milliseconds, so 2000 means 2 seconds.
Complete the code to cancel a scheduled timeout using its ID.
const timerId = setTimeout(() => { console.log('Run later'); }, 3000);
clearTimeout([1]);null or the function name.You must pass the timer ID returned by setTimeout to clearTimeout to cancel it.
Fix the error in the code to properly cancel the timeout.
let id = setTimeout(() => console.log('Oops'), 5000); clearTimeout([1]);
timeoutId.The variable id holds the timer ID and must be passed to clearTimeout.
Fill both blanks to schedule a message and then cancel it before it runs.
const [1] = setTimeout(() => console.log('Bye!'), 4000); [2]([1]);
setTimeout instead of clearTimeout to cancel.Store the timer ID in timer and pass it to clearTimeout to cancel.
Fill all three blanks to create a timeout, cancel it, and then schedule a new one.
const [1] = setTimeout(() => console.log('First'), 3000); [2]([1]); const [3] = setTimeout(() => console.log('Second'), 3000);
Use firstTimer to store the first timeout, cancel it with clearTimeout, then create secondTimer for the new timeout.
