Complete the code to import the URL class from the 'url' module.
const { [1] } = require('url');The URL class is used to parse and manipulate URLs in Node.js.
Complete the code to create a new URL object from a string.
const myUrl = new URL([1]);The URL constructor expects a string representing the full URL.
Fix the error in accessing the hostname property of the URL object.
console.log(myUrl.[1]);The hostname property returns only the domain name without port.
Fill both blanks to extract the pathname and search parameters from the URL.
const path = myUrl.[1]; const params = myUrl.[2];
pathname gives the path part of the URL, and searchParams provides an easy way to work with query parameters.
Fill all three blanks to add a new query parameter and get the full updated URL string.
myUrl.[1].append('[2]', '[3]'); console.log(myUrl.href);
Use searchParams.append to add a new query parameter. Then href shows the full URL string with the new parameter.