// Max Stock Profit

/*RULES:
  Takes in array of prices as parameters
  Returns max possible profit of the day
  If there is no possible profit, return -1
  Else, return profit
*/

/*PSEUDOCODE
  1) Create variables lowPoint and maxPoint, make the very first element both lowPoint and maxPoint just to start.
  2) Loop through array
    2a) For each element, compare each variable.
    2b) If element[i] < lowPoint, lowPoint = element[i]
    2c) If element[i] > maxPoint, maxPoint = element[i]
  3) maxPoint - lowPoint
    3a) If 0 || positive number,  return profit
    3b) Else, return -1
*/
@@ -587,8 +587,496 @@
 rn -1%0A*/
+%0A%0Afunction maxStockProfit(arr)%7B%0A  var maxProfit = -1;%0A  var buyPrice = 0;%0A  var sellPrice = 0;%0A%0A  var changeBuyPrice = true;%0A%0A  for (var i = 0; i %3C arr.length; i++)%7B%0A    if (changeBuyPrice)%7B%0A      buyPrice = arr%5Bi%5D;%0A    %7D%0A    sellPrice = arr%5Bi + 1%5D;%0A%0A    if (sellPrice %3C buyPrice)%7B%0A      changeBuyPrice = true;%0A    %7D else %7B%0A      var tempProfit = sellPrice - buyPrice;%0A      if (tempProfit %3E maxProfit) maxProfit = tempProfit;%0A      changeBuyPrice = false;%0A    %7D%0A  %7D%0A  return maxProfit;%0A%7D

Add working response