Skip to content

Commit f63268d

Browse files
committed
getTotal fn to accomodate NaN
1 parent ebf7a28 commit f63268d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/javascript/projects/modelling/tile_grid.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export class NumericTileGrid extends TileGrid {
309309
}
310310

311311
getTotal(): number {
312-
return this.data.reduce((a, b) => a + b, 0)
312+
return this.data.reduce((a, b) => (isNaN(a) ? 0 : a) + (isNaN(b) ? 0 : b), 0)
313313
}
314314

315315
toJSON(): TileGridJSON {

0 commit comments

Comments
 (0)