DAY11:Disemvowel Trolls


Posted by birdbirdmurmur on 2023-07-24

題目連結:

Disemvowel Trolls

解法:

初版

function disemvowel(str) {
  return str.replace(/[aeiouAEIOU]/g, '');
}

修正版

function disemvowel(str) {
  return str.replace(/[aeiou]/gi, '');
}

筆記:

使用replace做替換
修正版從/g/gi
從全域變成全域不分大小寫


#javascript #Codewars #replace







Related Posts

同步 & 非同步(2) - event loop & macro / micro task

同步 & 非同步(2) - event loop & macro / micro task

跟你朋友介紹 Git

跟你朋友介紹 Git

About Me || 【閱讀激發思考,寫作捕捉思路】

About Me || 【閱讀激發思考,寫作捕捉思路】


Comments