Reputation: 1973
I have a string in this format
strb= str1+ ' ' + str2
<span>{{strb}}</span>
How can I change this to display it backwards
Upvotes: 1
Views: 93
Reputation: 2843
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'
Upvotes: 2