Javascript Array Reduce Initial Value And Slope