Code Error

https://www.codecademy.com/code-challenges/code-challenge-maximize-stock-trading-profit-javascript

  let profit=[0];
  for(let first of stockPrices){
    for(let i of stockPrices){
      if(i-first>profit[profit.length-1]){
        let curr=i-first
        profit.push(first);
        profit.push(i)
        profit.push(curr)
      }
    }
  }
 
  let first=stockPrices.indexOf(profit[profit.length-3]);
  let i=stockPrices.indexOf(profit[profit.length-2]);
  return [first, i]

}

// Leave this so we can test your code:
module.exports = maxProfitDays;
console.log(maxProfitDays([2,6,4,45,7,6]))

Can you tell us what you are having trouble with?

My code is logging the correct answer but it says my code has an error