Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MorenoMdz/26532beea7112b7ce1d95b599839e637 to your computer and use it in GitHub Desktop.
Save MorenoMdz/26532beea7112b7ce1d95b599839e637 to your computer and use it in GitHub Desktop.
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