I need help splitting strings in an array and rearranging them so the last name comes first followed by a comma. For example, "Stephen Curry" should become "Curry, Stephen."
This task is really confusing me. I've attempted it multiple times without success. :(
function rearrangeNames(){
var warriorsArray = new Array(5);
warriorsArray[0] = "Stephen Curry";
warriorsArray[1] = "Andre Iguodala";
warriorsArray[2] = "Klay Thompson";
warriorsArray[3] = "Andrew Bogut";
warriorsArray[4] = "David Lee";
var newName = warriorsArray[0].split(' ');
return newName[1] + ', ' + newName[0];
}
rearrangeNames();