-3

I've number i.e. 12345678 and I want to change it to the following format [12,34,56,78]. How can I do that?

2
  • 4
    please make an attempt and share it before asking for help Commented Oct 31, 2019 at 12:33
  • Can you show us something you have tried already (some code)? Commented Oct 31, 2019 at 12:33

1 Answer 1

4

You can use match

var str = '12345678';
console.log(str.match(/.{1,2}/g).map(Number));

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.