You could have more than one space in a name though. You could do something like `return name.shift() + ', ' + name.join(' ');`

Nit: above (and other places), you should split by string instead of RegExp if you can.