Last active
September 3, 2018 12:28
-
-
Save spolat/b86016c0a086adc0d5fe374e61d7b6b2 to your computer and use it in GitHub Desktop.
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
let my_object = [ | |
{ | |
value: "", | |
class: "A" | |
}, | |
{ | |
value: "", | |
class: "B" | |
}, | |
{ | |
value: "", | |
class: "C" | |
} | |
]; | |
let myArray = ["value1", "value2", "value3"]; | |
my_object.map((item, index) => { | |
item.value = myArray[index]; // assign item.value by current index | |
}); | |
console.log(JSON.stringify(my_object)); | |
//[{"value":"value1","class":"A"},{"value":"value2","class":"B"},{"value":"value3","class":"C"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment