DEV Community

Discussion on: Daily Challenge #39 - Virus

Collapse
 
kvharish profile image
K.V.Harish

My solution in js

const cleanVirus = (sentence) => sentence.charAt(0).toUpperCase() + sentence.toLowerCase()
                                         .replace(/ie/g, 'ei')
                                         .replace(/[.+]\s\w/g, (str) => `. ${str[str.length -1].toUpperCase()}`)
                                         .slice(1);

As others mentioned this solution will change all the proper words with ie to ei and changes the first character of a noun to lowercase.