URLs have quite a few sections. Some are required, some are not.
Let's use the URL API again. This time, we'll parse a URL and print all the different parts. We'll learn more about each part later, for now, let's just split and print a URL!
Complete the printURLParts function. It should print all the parts of a URL. For example, given this URL:
http://testuser:[email protected]:8080/testpath?testsearch=testvalue#testhash
Your code should print:
protocol: http:
username: testuser
password: testpass
hostname: testdomain.com
port: 8080
pathname: /testpath
search: ?testsearch=testvalue
hash: #testhash
Use the following properties on the URL object:
protocolusernamepasswordhostnameportpathnamesearchhashThe URL object does not have enumerable properties to iterate over. You'll need to manually log each property.