Skip to content

Commit a001cc8

Browse files
Merge pull request akshitagit#100 from arwysyah/arwysyah
add simple javascript matrix
2 parents 296538b + c0c71bc commit a001cc8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Maths/matrix.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class Matrix {
2+
constructor(row,coloumn){
3+
this.rows = row
4+
this.col = coloumn
5+
this.matrix=[]
6+
for (let i = 0; i<this.rows ;i++){
7+
this.matrix[i]=[]
8+
for (let k = 0;k<this.col;k++){
9+
this.matrix[i][k]=0
10+
}
11+
}
12+
console.table(this.matrix)
13+
}
14+
fill(n){
15+
for (let i = 0; i<this.rows ;i++){
16+
this.matrix[i]=[]
17+
for (let k = 0;k<this.col;k++){
18+
this.matrix[i][k]=n
19+
}
20+
21+
}
22+
console.table(this.matrix)
23+
}
24+
generate(){
25+
for (let i = 0; i<this.rows ;i++){
26+
this.matrix[i]=[]
27+
for (let k = 0;k<this.col;k++){
28+
this.matrix[i][k] = Math.floor(Math.random()*10)
29+
}
30+
31+
}
32+
// console.table(this.matrix)
33+
}
34+
35+
}
36+
37+
38+
let t = new Matrix(3,2)
39+
let j = (t.Matrix)
40+
let add =k.fill(5)
41+
// simple program to generate javascript matrix

0 commit comments

Comments
 (0)