Hi kirupa!. There’s a typo on the code for the section “The old school way”. I thing it should be:
var names = [“marge”, “homer”, “bart”, “lisa”, “maggie”];
var newNames = [];
for (var i = 0; i < names.length; i++) {
var name = names[i];
var firstLetter = name.charAt(0).toUpperCase();
newNames.push(firstLetter + name.slice(1));
}
console.log(newNames);
Thanks for pointing those mistakes out! It should be fixed now
var names = ["marge", "homer", "bart", "lisa", "maggie"];
var newNames = [];
for (var i = 0; i < names.length; i++) {
var name = names[i];
var firstLetter = name.charAt(0).toUpperCase();
newNames.push(firstLetter + name.slice(1));
}
console.log(newNames);
Hi Kirupa!
In “Getting One Value from an Array of Items”, how does the total become 31 using reduce?
I thought reduce was simply adding the array up in this section’s example, like 1+2+3+4… etc, but I’ve tried by testing the code example in the console and it returns 78 so I’m not sure.
Thank you!
@emllew - you are right! It is a bug in my version. It should be 78. I will fix the code in a few moments.