DEV Community

Discussion on: Daily Challenge #39 - Virus

Collapse
 
ynndvn profile image
La blatte • Edited

Well, this solution will work in every case but won't be able to handle the 21775 "ie" words:

antidote=(s)=>s.split`. `.map(b=>{b=b.replace(/ie/gi,'ei');return b[0].toUpperCase()+b.slice(1).toLowerCase()}).join`. `
antidote("He haD iEght ShOTs of CAffIEne. aFter thaT HE WenT tO SleeP.")
// "He had eight shots of caffeine. After that he went to sleep."
Collapse
 
alvaromontoro profile image
Alvaro Montoro

I was doing something like this. Then I deid testing.

Collapse
 
mangelsnc profile image
Miguel Ángel Sánchez Chordi

There's a known set of rules to avoid handle all the "ie" words:

en.wikipedia.org/wiki/I_before_E_e...