split string into equal chunks javascript

Solutions on MaxInterview for split string into equal chunks javascript by the best coders in the world

showing results for - "split string into equal chunks javascript"
Clara
05 Oct 2016
1var str="hello how are you"
2var size=3
3console.log(str.match(new RegExp('.{1,' + size + '}', 'g')))
4//returns ["hel","lo ","how"," ar","e y","ou"]