1

I have a string in this format

strb= str1+ ' ' + str2

  <span>{{strb}}</span>

How can I change this to display it backwards

2
  • 1
    What is your framework? You can use split Commented Apr 22, 2020 at 10:55
  • Please tag with angular or angularjs where necessary Commented Apr 22, 2020 at 11:50

1 Answer 1

2

You can split your string at , to get first name and last name separately. This will literally cut away the parts you pass as a prop to your .split() function and return an array with the leftover pieces of your string.

const names = fullName.split(', '); //['BROWN', 'MARY'];
const firstName = names[1]; //'MARY'
const lastName = names[0]; //'BROWN'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.