Answers for "Reduce array to a single string using reduce"

0

Reduce array to a single string using reduce

var authorString = authors.reduce(function(prevVal,currVal,idx){
    return idx == 0 ? currVal : prevVal + ', ' + currVal;
}, '')
console.log(authorString);
Posted by: Guest on July-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language