I want to initialize and populate a two-dimensional array, but my solution doesn't seem to work. It only returns a function, not a value.
class Board{
constructor(width,height,cols,rows)
{
this.width=width;
this.height=height;
this.cols=cols;
this.rows=rows;
this.array= function(){
let array=[];
for(let i=0;i<this.cols;i++)
{
array[i]=[];
for(let j=0;j<this.rows;j++){
array[i][j]=0;
}
}
return array;
}
}