function splitArrIntoChunks(arr, size) {
var chunks = [], len = arr.length, i;
for (i = 0; i < len; i += size) {
chunks.push(arr.slice(i, i + size));
}
return chunks;
}
function prettifyNumView(num, size) {
var arr = num.toString().split('').reverse();
var chunks = splitArrIntoChunks(arr, size);
return chunks
.reverse()
.map(chunk => chunk.reverse().join(''))
.join(' ');
}
prettifyNumView(1000001, 3);