Skip to content

Commit 9f4fbb8

Browse files
authored
fix: stop rowEchelon mutating its input matrix
Change result assignment to create a copy of the matrix.
1 parent 5c39e87 commit 9f4fbb8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎Maths/RowEchelon.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const rowEchelon = (matrix) => {
114114

115115
let numRows = matrix.length
116116
let numCols = matrix[0].length
117-
let result = matrix
117+
let result = matrix.map((row) => [...row])
118118

119119
// Iterate through the rows (i) and columns (j) of the matrix.
120120
for (let i = 0, j = 0; i < numRows && j < numCols; ) {

0 commit comments

Comments
 (0)