Показываем пример попроще
function reduce() {
let a = [1, 'a', 3, 3, 3, 'f'];
console.log(
a.reduce(
(acc, v) => acc + (typeof v == 'number' ? v : 0),
100
)
);
}
и посложнее
function reduce() {
let a = [
[1, 'a', 3, 3, 3, 3, 3, 3, 'f'],
[1, 'a', 3, 3, 3, 3, 3, 3, 'f'],
[1, 'a', 3, 3, 3, 3, 3, 3, 'f']
];
console.log(
a.reduce((acc, row) =>
acc + row.reduce(
(acc2, v) => acc2 + (typeof v == 'number' ? v : 0),0),
)
);
}
