본문 바로가기
알고리즘/Codewars

[Codewars] Exclamation marks series #11: Replace all vowel to exclamation mark in the sentence (8 kyu) / JavaScript

by fluss 2023. 3. 14.

https://www.codewars.com/kata/57fb09ef2b5314a8a90001ed

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Replace all vowel to exclamation mark in the sentence. aeiouAEIOU is vowel.

 

Examples

replace("Hi!") === "H!!"
replace("!Hi! Hi!") === "!H!! H!!"
replace("aeiou") === "!!!!!"
replace("ABCDE") === "!BCD!"

 

코드

function replace(s){
  return s.replace(/[aeiou]/gi, '!')
}

댓글