Question: I have an array of 11 objects which contain JSON data. I wrote a function in which a new key with a zero value is added to each of the objects. Now I want to update the value of the said key in all 11 objects. The data is stored in an array2 with 11 numbers. My for loop doesn't seem to work for this, and the only way to do it (so far) is to hard code it. Does anyone has a suggestion how this can be done? 

The desired outcome would be this: 

array[0].new\_key = array2[0]; 
 array[1].new\_key = array2[1]; 

The first art of the function, before the for loop with j, is for adding the new key into the original array and that part works. 

```
    for (i = 0; i < array.length; i++) {
        array.map(i => i.new_key = 0);
        console.log(array)
        for (j = 0; j < array2.length; j++) {
            array[i].new_key = array2[j];
            console.log(array)
        }
    }
}```

```

Answer: 
I split it into two functions, I realized that I made it too complicated and it didn't made sense. I wrote a second function that only updates all the key values, so indeed, I removed the inner loop as it was not needed. Thank you for the help.
~~`.map()` does not modify the original array:~~

> 
> The map() method creates a new array with the results of calling a
>  provided function on every element in the calling array.
> 
> 
> 

You will want to get the result of the map by assigning it to a variable, and see what is happening there. Right now you don't do anything with it, so it will just disappear.

While the above is true for maps, in this case the original array is being modified as we access the object's properties and modify them there.