querubin,
function str_pack(arr) {
var acc = 0, str = '';
for( i in arr ){
if( isNaN(arr[i]) )
str = str + (acc > 0 ? acc : '') + arr[i],
acc = 0;
else
acc = +arr[i] + acc;
}
if( acc > 0 ) str += acc;
return str;
}
console.log(str_pack([1,1,'Q',1,'R']));
console.log(str_pack([1,1,1,'Q',1,1,'R',1]));
console.log(str_pack([1,1,'N','W',1,1,1,'Q']));