123456789 |
- const arr = ["0", 5, 3, "string", null];
- const sum = params => {
- const multiply = (previousValue, currentValue) => (typeof currentValue === 'number' ? previousValue * currentValue : previousValue);
- return params.reduce(multiply, 1);
- }
- console.log(sum(arr)); // 15
|