Complete the code to log 'Hello' after 1 second using setTimeout.
setTimeout(() => { console.log('Hello'); }, [1]);The setTimeout function delays execution by the given milliseconds. 1000 ms equals 1 second.
Complete the code to add a function to the event loop queue using Promise.resolve().then.
Promise.resolve().[1](() => console.log('Done'));
The then method schedules the callback to run after the current call stack, using the microtask queue.
Fix the error in the code to correctly log 'First' then 'Second' using setTimeout.
console.log('First'); setTimeout(() => console.log('Second'), [1]);
The delay must be a number, not a string. 1000 means 1 second delay.
Fill both blanks to create a microtask that logs 'Microtask' and a macrotask that logs 'Macrotask'.
Promise.resolve().[1](() => console.log('Microtask')); setTimeout(() => console.log('Macrotask'), [2]);
then schedules a microtask, which runs before macrotasks like setTimeout. Delay 0 means run as soon as possible after current tasks.
Fill all three blanks to create a code that logs 'Start', then a microtask 'Middle', then a macrotask 'End'.
console.log([1]); Promise.resolve().[2](() => console.log('Middle')); setTimeout(() => console.log([3]), 0);
Logging 'Start' first, then scheduling a microtask with then to log 'Middle', and a macrotask with setTimeout to log 'End'. This shows event loop order.