Mixed Juices Export Error

Here is the code and I tested this in another IDE and it worked. I am getting the Unexpected token 'export' and can’t figure out why. Can someone check this and see if it works. Its the text book answer and I keep getting this error. Before I got other errors so I am not sure there is a bug.
Thx

export function limesToCut(wedgesNeeded, limes) {
let totalWedges = 0;
let limesCut = 0;
let wedges = 0;

while ((limesCut < limes.length) && (totalWedges <= wedgesNeeded)) {
switch (limes[limesCut])
{
case ‘small’:
wedges = 6;
break;
case ‘medium’:
wedges = 8;
break;
case ‘large’:
wedges = 10;
break;
}
totalWedges += wedges;

if (wedgesNeeded > 0) {
  limesCut++;
}

return limesCut;
}

The code you posted is not completed fenced with a code block:

```javascript
// your code here
```

So it’s a bit hard to figure out if you copied the code correctly / missed a part. If you format the code correctly (two or four space / tab indentation), you’ll see that the function limesToCut is not closed. That likely caused the error you are seeing.

1 Like