I need to make a function that reads a string input and converts the odd indexed characters in the string to upperCase and the even ones to lowerCase.
function alternativeCase(string){
for(var i = 0; i < string.length; i++){
if (i % 2 != 0) {
string[i].toUpperCase();
}
else {
string[i].toLowerCase();
}
}
return string;
}
How to fix my code?
Try this: