Asked
Viewed
87 times
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?
asked Oct 31, 2019 at 12:32
2
You can use match
var str = '12345678';
console.log(str.match(/.{1,2}/g).map(Number));
answered Oct 31, 2019 at 12:35
Start asking to get answers
Find the answer to your question by asking.
Ask question
Explore related questions
See similar questions with these tags.