I have an string that I would like to turn into an array, taking every 3 characters in the string as an item in that array. For example"
var theString = "hello there!"
// the resulting array will look like this
["hel", "lo ", "the", "re!"]
I have an string that I would like to turn into an array, taking every 3 characters in the string as an item in that array. For example"
var theString = "hello there!"
// the resulting array will look like this
["hel", "lo ", "the", "re!"]
You could try something like this:
var theString = "hello there!";
var arr = [];
for (var i = 0; i < theString.length; i+=3) {
arr.push(theString.substring(i, i+3));
}