Created
May 1, 2018 18:30
-
-
Save MorenoMdz/26532beea7112b7ce1d95b599839e637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LetterChanges(str){ | |
// Firt get all the leters, global insensitive, then run a function that receives a char | |
// Takes char, if it is z or Z change it to 'a' | |
// Then convert to charCode and add 1. | |
let converted = str.replace(/[a-z]/gi, function(char){ | |
return(char === 'z'|| char ==='Z') ? 'a' : String.fromCharCode(char.charCodeAt() + 1); | |
}); | |
// Find if the letter is a vowel the Upper Case it and replace it to the array. | |
let capsVowel = converted.replace(/a|e|i|o|u/gi, function(vowel) { | |
return vowel.toUpperCase(); | |
}); | |
return capsVowel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment