📅  最后修改于: 2022-03-11 15:04:22.428000             🧑  作者: Mango
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'