I need to create an object using an array as keys and another object with default properties as values. I am unsure of how to loop through and assign the key/value pairs to the new object. Can you help me out? Thank you!
The object myFinalObj
is initially empty.
This is my starting object:
var startingObj = {
'one' : {'default': 1, 'name': 'un'},
'two' : {'default': 2, 'name': 'deux'},
'three': {'default': 3, 'name': 'trois'}
}
Here is my array:
var myArray = ['one', 'two', 'three'];
This is what my final object should look like:
var myFinalObj = {
'one' : 1,
'two' : 2,
'three' : 3
}