Skip to content

Commit

Permalink
Fix incorrect matrix initialization (#291)
Browse files Browse the repository at this point in the history
* fix incorrect matrix initialization

* Apply change to other array as well

---------

Co-authored-by: Nathan Bierema <nbierema@gmail.com>
  • Loading branch information
rexxars and Methuselah96 authored Aug 24, 2023
1 parent 1e76171 commit 4cb5805
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/filters/lcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const lengthMatrix = function (array1, array2, match, context) {
let x, y;

// initialize empty matrix of len1+1 x len2+1
const matrix = [len1 + 1];
const matrix = new Array(len1 + 1);
for (x = 0; x < len1 + 1; x++) {
matrix[x] = [len2 + 1];
matrix[x] = new Array(len2 + 1);
for (y = 0; y < len2 + 1; y++) {
matrix[x][y] = 0;
}
Expand Down

0 comments on commit 4cb5805

Please sign in to comment.