You can check the current value of loop in .map() and return 0 if the value is 0:
.map()
var arr = [1, 4.5, 0, 0, 3]; var sum = 0; var result = arr.map(value => value ? sum += value : 0); console.log(result);