Number of Laser Beams in a Bank LeetCode solution in JavaScript

1
var numberOfBeams = function (bank) {
2
let totalBeams = 0;
3
const maximumSecurityDevicePerRow = bank
4
.map((row) => (row.match(/1/g) || []).length)
5
.filter(Boolean);
6
for (let index = 0; index < maximumSecurityDevicePerRow.length - 1; index++)
7
totalBeams +=
8
maximumSecurityDevicePerRow[index] *
9
maximumSecurityDevicePerRow[index + 1];
10
return totalBeams;
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0