Hello Tsoding,
the operation of printing full rows and the last reminder row can both happen in a single impl.
the inner loop checks for both ROW count and also preserve overall SIZE limit.
here is a runnable example in JS:
var data = [...new Array(100)].map((_,i)=>i+101);
var row_size = 7;
for(let i=0; i<data.length; ++i) {
var out = " ";
for (let w=0; w<row_size && i<data.length; ++w, ++i) {
out += data[i].toString() + ", ";
}
console.log(out);
}
Hello Tsoding, the operation of printing full rows and the last reminder row can both happen in a single impl. the inner loop checks for both ROW count and also preserve overall SIZE limit.
here is a runnable example in JS: