Skip to content

Instantly share code, notes, and snippets.

@shockwaves
Last active March 17, 2017 09:50
Show Gist options
  • Save shockwaves/6648791da3201e1a594ac99761d8f01a to your computer and use it in GitHub Desktop.
Save shockwaves/6648791da3201e1a594ac99761d8f01a to your computer and use it in GitHub Desktop.
let Table = {
increment: 0,
init(rows,columns){
this.rows = rows;
this.columns = columns;
this.matrix = this.generateMatrix();
},
generateMatrix(){
let arr = [];
for(let i=0; i<this.columns; i++){
arr[i] = new Array(this.columns);
for(let j=0; j<this.rows; j++){
arr[i][j] = {id: this.increment++, amount: Math.random()}
}
}
return arr;
}
}
Table.init(3, 3);
console.log(Table.matrix);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment