const r = 4;
const c= 3;
const a = new Array(r).fill(new Array(c).fill(-1));
const fillSquareMatrix = (size) => {
return Array(size)
.fill()
.map((u,y) => Array(size)
.fill()
.map((u,x) => y * size + x + 1));
};
console.log(fillSquareMatrix(3));