function list(names) { var xs = names.map((p) => p.name); var x = xs.pop(); return xs.length ? xs.join(", ") + " & " + x : x || ""; } // Example: // list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ]) // returns 'Bart, Lisa & Maggie'