How to split string to strings of equal length in JavaScript?
Solution
'abcdabcdabcdabcdabcd'.match(/.{1,4}/g)
// ['abcd', 'abcd', 'abcd', 'abcd', 'abcd']
Here's original StackOverflow answer.
Context
In today's Advent of Code challenge, I had to simulate drawing pixels on 40x6 CRT screen. First I computed li...
blog.macieksitkowski.com1 min read