const rows = 6;
const columns = 10;
let result = '';
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const index = row * columns + column + 1;
result += index.toString().padStart(2, '0');
if (column < columns - 1) {
result += ' ';
}
}
if (row < rows - 1) {
result += '\n';
}
}
console.log(result);
function createTable(rows, cols) {
const maxLen = `${rows * cols}`.length;
return [...Array(rows)]
.map((n, i) => [...Array(cols)]
.map((m, j) => `${cols * i + j + 1}`.padStart(maxLen, 0))
.join(' '))
.join('\n');
}
function createTable(rows, cols) {
const zeroStr = Array(1 + Math.ceil(Math.log10(rows * cols + 1))).join(0);
let result = '';
for (let i = 0; i < rows; i++) {
result += i ? '\n' : '';
for (let j = 0; j < cols; j++) {
result += (j ? ' ' : '') + (zeroStr + (cols * i + j + 1)).slice(-zeroStr.length);
}
}
return result;
}
let out1 = document.querySelector('.out1');
const ki = () => {
let out = '';
for (let k = 0; k <= 6; k++) {
for (let i = 0; i <= 9; i++) {
if (i + 1 + k * 10 < 10) {
out += '0';
}
if (i + 1 + k * 10 <= 50) {
out += i + 1 + k * 10;
}
out += ' ';
}
out += '<br>';
}
out1.innerHTML = out;
}
ki();