Вариант ...
function foo(f, c) {
var c = c - 1, a = f.split(""), e = a.length - c;
for (var b = 0; b < e; b++)
for (var d = 1; d <= c; d++) a[b] += a[b + d];
return a.slice(0, e)
};
var str = "abcdef";
alert([foo(str,1),foo(str,2),foo(str,3)].join('\n'))