Vote count:
0
For those familiar with this quiz, I'm trying to take a string argument and convert each letter to the letter that follows in the alphabet. EG, the argument "abc" should become "bcd".
The first portion of my code works. It takes the first letter of the argument and converts it. Now I'm trying to do this for each letter of the argument and then concatenate the results into one string as the output. This part isn't working. I'm getting the error, "SyntaxError: Unexpected token ;"
function LetterChanges(str) {
var string = str.toLowerCase()
var alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
var currentStr = string[0];
var currentAlpha = alphabet.indexOf(currentStr);
var nextAlpha = (currentAlpha + 1);
//the code above this works. The code below results in an error
while (i = 1;i < string.length; i++){
var output += nextAlpha;
var n = n+1;
};
return output;
}
I'm a beginner, so thanks in advance.
asked 57 secs ago
CoderByte JavaScript Letter Changes - first steps
Aucun commentaire:
Enregistrer un commentaire