Computer scienceBackendNode.jsCore ConceptsInternal modulesHTTP server

Intro to URL module

Parse and print

Report a typo

You are given the following URL string — "https://jsonplaceholder.typicode.com/posts". You have to parse the URL string and print its path as an array. Complete the code given below.

The url module is already imported using the require method and is stored in the const url variable. Do not print the output, testing is handled internally.

Create a URL object and use split method on the object to get an array of path

Sample Input 1:

Sample Output 1:

[ '', 'posts' ]
Write a program in JavaScript
const urlString = ...

const urlObject = ...
const arrayOfPath = ...
___

Create a free account to access the full topic