To split a string into segments of n characters with JavaScript, we call the match
method.
For instance, we write
const str = "abcdefghijkl";
console.log(str.match(/.{1,3}/g));
to call str.match
with a regex the matches groups of 1 to 3 characters in the str
array.