Answers for "reduce an array of objects to string"

1

reduce an array of objects to string

var authors = [{
  name: "a"
}, {
  name: "b"
}, {
  name: "c"
}];
var result = authors.reduce(function(author, val, index) {
  var comma = author.length ? ", " : "";
  return author + comma + val.name;
}, '');
console.log(result);
Posted by: Guest on July-20-2020

Code answers related to "reduce an array of objects to string"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language