JavaScript Mixed Juices

I cannot solve the remainingOrders problem in the Mixed Juices exercise. Could anyone please help?

Hey! Could you share your progress so far please? Where are you stuck? What have you tried so far? What ideas have you got about what to try next? Then someone will be more likely to be able to give you a helping hand :smile:

export function remainingOrders(timeLeft,orders){
  while(timeLeft>0&&orders.length>0){
      timeLeft-=timeToMixJuice(orders[0]);
      orders.shift(); //removes first element from array
  }
  return orders;
}
2 Likes

Hi Rahul,

Your function does NOT consider the fact that orders could become empty while you still have timeLeft. So, please consider adding another condition to your while loop.

Yes Sir, you are right, thanks for pointing out my mistake : )