1

I'm trying to figure out how to split a string into two parts like

Supporter->VIP

in NodeJS. For example:

var Old = Supporter
var New = VIP

Would I have to use .split() somehow? Or is there a way I can use a RegExp? The -> would always be in between the two.

Sorry I couldn't be more descriptive. I'm a bit lost.

1 Answer 1

4

You could split the string and take a destructuring assignment.

var [o, n] = 'Supporter->VIP'.split('->');

console.log(o, n);

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.