-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?

1 Answers1

4

You can use match

var str = '12345678';
console.log(str.match(/.{1,2}/g).map(Number));
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43