JS juice problem, while stopping to early

I’m baffled. I’ve checked dozens of times with various logs but I can’t imagine why this While loop stops early. The conditions are still true when the loop stops but it refuses to keep going.

export function limesToCut(wedgesNeeded, limes) {
  let wedgesCut = 0;
  let limesCut = 0;
  if (limes.length === 0) {return 0};
  if (wedgesNeeded === 0) {limesCut = 0; return limesCut};
  if (limesCut >= limes.length) {return limes.length};
  while ((limesCut < limes.length) && (wedgesCut < wedgesNeeded)) {
    let currentLime = limes.shift();
    switch (currentLime) {
      case 'small':
        wedgesCut += 6;
      case 'medium':
        wedgesCut += 8;
      case 'large':
        wedgesCut += 10;
  console.log('Limes cut: ' + limesCut);
  console.log('Wedges cut: ' + wedgesCut);
  return limesCut;

It would be helpful to also share the failed tests.

You may want to consider closely the first condition, (limesCut < limes.length). What are these values each loop iteration?

I just realized that, too. Since I’m shifting an item off each iteration, the array length isn’t what I’m expecting. I don’t know what else to compare it to, and I’m not entirely sure why I’m comparing it at all. If I remove that comparison altogether I get an infinite loop, except the (wedgesCut < wedgesNeeded) should stop the loop from iterating again.

You want to loop over the lime wedges, right? Can you write a while loop that does only that?

I found another solution, I assigned the initial value passed into the function to its own variable and compared limesCut to that new variable. All tests for the portion have passed. Thanks for the help!