Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created September 10, 2016 17:40
Show Gist options
  • Save dengjonathan/2c1c44d19e66d1007b97e0cfdbe71898 to your computer and use it in GitHub Desktop.
Save dengjonathan/2c1c44d19e66d1007b97e0cfdbe71898 to your computer and use it in GitHub Desktop.
using for loop to iterate through array
var i;
var names = ['jon', 'jane', 'jack'];
// imperative programming
for (i = 0; i < names.length; i++) {
names[i] = names[i][0].toUpperCase() + names[i].slice(1);
}
console.log(names) // ['Jon', 'Jane', 'Jack']
console.log(i) // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment