JavaScript Challenge 67

황상진·2022년 8월 11일
0

JS-Challenge

목록 보기
2/4

Domain name

https://www.instagram.com/p/Cgyx5cFs2ps/

function domainName(url){
  let res = '';

  res = url.split('//');
  if(res.length==1){
    res = res.join('')
  }
  else{
    res = res[1];
  }
  res = res.split('.');
  res = res[res.length-2]
  return res;
}

console.log(domainName('https://google.com'));
console.log(domainName('https://www.instagram.com/p/Cgyx5cFs2ps/'))
console.log(domainName('https://challenges.fabiobergmann.com/home'));

console.log(domainName('instagram.ffln1-1.fna.fbcdn.net/'));
profile
Web FrontEnd Developer

0개의 댓글