I've solved the problem below just would like some feedback?
The function
LetterChanges(str)
takes a str parameterReplace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return this modified string.
function LetterChanges(str) {
var newString = '';
var newCode = 0;
var len = str.length;
var i = 0;
for (; i < len; i++){
/*Using ASCII code: this if statement return true if character at
str[i] is a - y*/
if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 121) {
//Assign ASCII code plus 1 to a variable newCode
newCode = str.charCodeAt(i) + 1;
/*Check to see newCode variable is a lower case vowel from ASCII
and if so, add capital of that vowel to newString variable, else
use newCode variable to add character to newString*/
if (newCode == 101) {
newString += String.fromCharCode(69);
} else if (newCode == 105) {
newString += String.fromCharCode(73);
} else if (newCode == 111) {
newString += String.fromCharCode(79);
} else if (newCode == 117) {
newString += String.fromCharCode(85);
} else {
newString += String.fromCharCode(newCode);
}
/*Using ASCII code: this if statement return true if character at
str[i] is z, in that case adding capital A*/
} else if (str.charCodeAt(i) == 122){
newString += String.fromCharCode(65);
/*else just add to newString i.e uppercase(question didn't specify),
symbols, number...*/
} else {
newString += str[i];
}
}
return newString;
}
function transform(str) {const replacements = 'bcdEfghIjklmnOpqrstUvwxyzA'; return str.replace(/[a-z]/g, char => replacements[char.charCodeAt(0) - 97]);}
\$\endgroup\$