Skip to main content
Participant
July 3, 2018
Question

script to flip name from last name, first name to first name last name

  • July 3, 2018
  • 1 reply
  • 1982 views

Is there a custom script to flip a name from last name, first name to first name last name?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 3, 2018

You can split the value using the comma as the delimiter and then reverse the two parts, like this:

var name1 = "Doe, John";

var name2 = name1.split(", ")[1] + " " + name1.split(", ")[0];

Edit: fixed a small mistake in the code

Princeplanet
Inspiring
July 5, 2018

Could you give an example how I could use this?  I'm just trying to see it in a real world example.

Thanks!

try67
Community Expert
Community Expert
July 6, 2018

What do you mean by "real world example"?