Convert array of strings into an array of objects

Use Array#map to convert each value into a different value:

var newArr = arr.map(function(value) {
  return {name: value};
});

Array#map applies the callback to each element in the array and returns a new array containing the return values of the callback.

Leave a Comment