reduce should return ret, not newArr