I am currently working on processing an array of objects that represent authors. My goal is to map through these objects and concatenate their names with some formatting applied. However, I seem to be encountering a challenge with this seemingly simple task.
const authors = [ { id: 1, name: 'Steven'}, {id: 2, name: 'Nick'}]
let names = authors.map( (a, i) => {
return `${a.name} is cool`
})
console.log(names)
// ["Steven is cool","Nick is cool"]
// while my desired output is "Steven is cool Nick is cool"
Is there a way for me to achieve the desired string format by mapping through the objects?
For instance, instead of getting individual strings like "Steven is cool"
and "Nick is cool"
, I aim to generate a single concatenated string like "Steven is cool Nick is cool"
.