//console.log(string_chop('w3resource'));
console.log(string_chop('w3resource',2));
//console.log(string_chop('w3resource',3));

function string_chop(str,chunk)
{
   // var temp= str.split('')
   // console.log(temp);
    var ar = [];
    for(var i=0 ; i<str.length ; i+=chunk)
    {
       /*ar.push(str[i]);
       ar.push(str[i+1]);
       ar.join(' ')
       console.log(ar);*/
       ar[i]=str[i];
       ar[i+1]=str[i+1];
       ar.join('')
       console.log(ar)
       
    }
  //  return ar.join(' ');
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: