forked from akshitagit/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix.js
More file actions
41 lines (36 loc) · 857 Bytes
/
matrix.js
File metadata and controls
41 lines (36 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Matrix {
constructor(row,coloumn){
this.rows = row
this.col = coloumn
this.matrix=[]
for (let i = 0; i<this.rows ;i++){
this.matrix[i]=[]
for (let k = 0;k<this.col;k++){
this.matrix[i][k]=0
}
}
console.table(this.matrix)
}
fill(n){
for (let i = 0; i<this.rows ;i++){
this.matrix[i]=[]
for (let k = 0;k<this.col;k++){
this.matrix[i][k]=n
}
}
console.table(this.matrix)
}
generate(){
for (let i = 0; i<this.rows ;i++){
this.matrix[i]=[]
for (let k = 0;k<this.col;k++){
this.matrix[i][k] = Math.floor(Math.random()*10)
}
}
// console.table(this.matrix)
}
}
let t = new Matrix(3,2)
let j = (t.Matrix)
let add =k.fill(5)
// simple program to generate javascript matrix