I have an array, which need to be the keys in my object. I also have an object with the same keys and a default property, which I need to set as the value to my keys in the object I need to build. I'm stuck at how to loop and set the key/values in the empty object. Thanks!!
myFinalObj starts off as an empty object.
My starting object
var startingObj = {
'one' : {'default': 1, 'name': 'un'},
'two' : {'default': 2, 'name': 'deux'},
'three': {'default': 3, 'name': 'trois'}
}
My Array
var myArray = ['one', 'two', 'three'];
My finished Object
var myFinalObj = {
'one' : 1,
'two' : 2,
'three' : 3
}
startingObj, you have the key, why you needmyArray?