Disemvowel Trolls

Lee·2022년 7월 14일
0

Algorithm

목록 보기
47/92
post-thumbnail

❓ Disemvowel Trolls

Q. 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.

✔ Solution

//#my solution
function disemvowel(str) {
   return str.match(/[^aeiou]/gi).join('');  
 }

//#other solution
function disemvowel(str) {
  return (str || "").replace(/[aeiou]/gi, "");
}
profile
Lee

0개의 댓글