I'm working on some code that should output the accumulation of a string eg.
abc would = A Bb Ccc
But when I test it the input and output get assigned abc and "" respectively, but once the for loop happens the code just stops and returns null.
Anyone can explain why? I tried SubString instead of charAt to no avail.
function accum(s) {
//storage
var input = s;
var output = "";
// capitalize first letter
for (var i = 0; i < s; i++) {
output = input.charAt(i);
output.toUpper();
for (var j = i; j < i; j++) {
output += output.toLower();
};
return output;
};
}
console.log(accum("abc"));
i < s.length? Did you mean.toUpperCase()and.toLowerCase()?