Answers for "Write a function that when given a URL as a string, parses out just the domain name and returns it as a string."

0

Write a function that when given a URL as a string, parses out just the domain name and returns it as a string.

//To extract hostname from string
function domainName(url){
  url = url.replace("https://", '');
  url = url.replace("http://", '');
  url = url.replace("www.", '');
  return url.split('.')[0];
};
Posted by: Guest on August-12-2021

Code answers related to "Write a function that when given a URL as a string, parses out just the domain name and returns it as a string."

Code answers related to "Javascript"

Browse Popular Code Answers by Language