Created
April 18, 2018 20:28
-
-
Save 6ui11em/5a2af6b49eaada64328465d7450efd90 to your computer and use it in GitHub Desktop.
Javascript array map #javascript #array
This file contains hidden or 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 numbers = [1, 4, 9]; | |
var doubles = numbers.map(function(num) { | |
return num * 2; | |
}); | |
// Logs [2, 8, 18] | |
console.log(doubles); | |
var data = [ | |
{ | |
name: 'Kyle', | |
occupation: 'Fashion Designer' | |
}, | |
{ | |
name: 'Liza', | |
occupation: 'Web Developer' | |
}, | |
{ | |
name: 'Emily', | |
occupation: 'Web Designer' | |
}, | |
{ | |
name: 'Melissa', | |
occupation: 'Fashion Designer' | |
}, | |
{ | |
name: 'Tom', | |
occupation: 'Web Developer' | |
} | |
]; | |
var names = data.map(function (item) { | |
return item.name; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment