Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting spaces between numbers in a string

Consider a string:

12345678

The desired output is:

1 2 3 4 5 6 7 8

How can this be split using JavaScript?

like image 201
Vicky Avatar asked Aug 14 '26 08:08

Vicky


1 Answers

'12345678'.split('').join(' ');
like image 84
David Hellsing Avatar answered Aug 16 '26 22:08

David Hellsing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!