Complete the code to print 'Hello, world!' to the console.
console.[1]('Hello, world!');
The console.log method prints messages to the console in JavaScript.
Complete the code to create a new Promise that resolves with 'Done'.
const promise = new Promise((resolve, reject) => { resolve([1]); });The Promise resolves with the string 'Done' using resolve('Done').
Fix the error in the async function to await the promise correctly.
async function fetchData() { const result = [1] promise; return result; }The await keyword pauses the async function until the promise resolves.
Fill both blanks to create a setTimeout that logs 'Hi' after 1 second.
setTimeout(() => { console.[1]('Hi'); }, [2]);console.log prints the message, and 1000 means 1000 milliseconds (1 second) delay.
Fill all three blanks to create a Promise that rejects with 'Fail' after 2 seconds.
const failPromise = new Promise(([1], [2]) => { setTimeout(() => { [2]('[3]'); }, 2000); });
The Promise executor takes resolve and reject. We call reject('Fail') after 2 seconds to reject the promise.
