function splitStringIntoChunks(str, length) {
const regex = new RegExp(`.{1,${length}}`, 'g');
return str.match(regex);
}
const inputString = "javascript c++ c python c#";
const chunkLength = 5;
const chunks = splitStringIntoChunks(inputString, chunkLength);
console.log(chunks);
/*
run:
[ 'javas', 'cript', ' c++ ', 'c pyt', 'hon c', '#' ]
*/