//console.log(string_chop('w3resource'));
console.log(string_chop('w3resource',2));
//console.log(string_chop('w3resource',3));
function string_chop(str, num)
{
var temp = str.split('');
// console.log(temp);
var ar = [];
for(var i =0 ; i<temp.length ; i=i+num)
{
for(var j =i ; j<(num+i) ; j++)
{
ar.push(temp[j]);
// console.log(j)
}
}
return ar;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: