```js function maxStockProfit(pricesArr) { const Price = { 'buy': 0, 'sell': 0, 'change': true }; return pricesArr.reduce((maxProfit, currentPrice, indx, arr)=> { Price.buy = (Price.change) ? currentPrice : Price.buy; Price.sell = arr[indx+1]; if(Price.sell < Price.buy) { Price.change = true; } else { let tempProfit = Price.sell - Price.buy; maxProfit = (tempProfit > maxProfit) ? tempProfit : maxProfit; Price.change = false; } return maxProfit; }, -1); } console.log(maxStockProfit([10,18,4,5,9,6,16,12])); ```