In fact, you have to reassign the array element:
for(var i = 1 ; i < newArr.length ; i++){ newArr[i] = newArr[i].charAt(0).toUpperCase(); }
The "toUpperCase ()" function returns a new line, but does not change the original.
You can check to make sure newArr[i] is an empty string if you get an input string with two consecutive dashes.
edit - noticed that SO contributor @lonesomeday correctly indicates that you also need to paste the rest of each line again:
newArr[i] = newArr[i].charAt(0).toUpperCase() + newArr[i].substr(1);
Pointy
source share