Created
September 10, 2016 17:40
-
-
Save dengjonathan/2c1c44d19e66d1007b97e0cfdbe71898 to your computer and use it in GitHub Desktop.
using for loop to iterate through array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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