【One topic per day】Disemvowel Trolls

前端题库,Javascript题集

Posted by Jerry on April 11, 2019

Disemvowel Trolls

Trolls are attacking your comment section!

A common way to deal with this situation is to remove all of the vowels from the trolls’ comments, neutralizing the threat.

Your task is to write a function that takes a string and return a new string with all vowels removed.

For example, the string “This website is for losers LOL!” would become “Ths wbst s fr lsrs LL!”.

Note: for this kata y isn’t considered a vowel.

reply

function disemvowel(str) {
  let vaild = ['a','e','i','o','u'];
  return str.split('').reduce((s,x)=>{
    return s += (vaild.includes(x.toLowerCase()))?'':x
  },'');
}

同Github,欢迎star