Skip to content

Commit 127b654

Browse files
committed
Bonus - Iteration ironhack-labs#8.2: Product of diagonals
1 parent c7afa55 commit 127b654

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/functions-and-arrays.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function greatestProductDiagonals(squareMatrix) {
277277
if (squareMatrix.length - colIndex >= 4 && squareMatrix.length - rowIndex >= 4) {
278278
tempRightDiagProduct = squareMatrix[rowIndex][colIndex] * squareMatrix[rowIndex + 1][colIndex + 1] * squareMatrix[rowIndex + 2][colIndex + 2] * squareMatrix[rowIndex + 3][colIndex + 3]
279279
}
280-
if (colIndex - squareMatrix.length >= 4 && rowIndex - squareMatrix.length >= 4) {
280+
if (squareMatrix.length - colIndex >= 4 && rowIndex >= 4) {
281281
tempLeftDiagProduct = squareMatrix[rowIndex][colIndex] * squareMatrix[rowIndex - 1][colIndex - 1] * squareMatrix[rowIndex - 2][colIndex - 2] * squareMatrix[rowIndex - 3][colIndex - 3]
282282
}
283283
if (tempRightDiagProduct > tempLeftDiagProduct && tempRightDiagProduct > product) {
@@ -291,8 +291,6 @@ function greatestProductDiagonals(squareMatrix) {
291291
}
292292

293293

294-
295-
296294
// The following is required to make unit tests work.
297295
/* Environment setup. Do not modify the below code. */
298296
if (typeof module !== 'undefined') {

0 commit comments

Comments
 (0)