Open EkaterinaRomankova opened 2 years ago
Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example:
function domainName(url){ let str = url.split("/") if (str[0].includes("http")) { str = str[2] } else { str = str[0] } str = str.split('.') if (str[0] === "www") { str = str[1] } else { str = str[0] } return str }
Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example:
function domainName(url){ let str = url.split("/") if (str[0].includes("http")) { str = str[2] } else { str = str[0] } str = str.split('.') if (str[0] === "www") { str = str[1] } else { str = str[0] } return str }