Complete the code to create a new URL object from a string.
const myUrl = new URL([1]);You need to pass the URL string as a quoted string to the URL constructor.
Complete the code to get the hostname from a URL object.
const hostname = myUrl.[1];host which includes port number.href which is the full URL string.The hostname property gives just the domain name without port.
Fix the error in accessing the pathname of a URL object.
const path = myUrl.[1];pathname as a function with parentheses.getPath.The pathname is a property, not a function, so no parentheses are needed.
Fill both blanks to create a URL object with a base URL.
const myUrl = new URL([1], [2]);
The first argument is the relative path, the second is the base URL string.
Fill all three blanks to extract the protocol, hostname, and port from a URL object.
const protocol = myUrl.[1]; const hostname = myUrl.[2]; const port = myUrl.[3];
host instead of hostname and port separately.Use protocol, hostname, and port properties to get these parts.
