I am trying to figure out why the following code results in an array of objects:
const startingArray = ['One', 'Two', 'Three', 'Four', 'Five'];
let endingArray = startingArray.map((nums) => {
return { nums }
});
console.log(endingArray)
The result would be an array of objects such as:
[{nums: 'One'}
{nums: 'Two'}...]
and continuing on through the end of the input array... I understand that the map() method creates a new array populated with the results of calling a provided function on every element in the calling array. So is it simply a matter of the fact that by wrapping the argument in curly braces the map method inherently sets the argument name as the key of an object literal and sets the value of the input array as the associated value of the respective key?