Cash Register https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register

Hello, could someone please help me clarify my error and how to correct it.

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register`

I’m working though the last Javascript project Cash Register. My code isn’t passing the test. The error message says:

SyntaxError: unknown: Unexpected token (72:0)

70 |
71 | checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);
> 72 |
| ^
Build failed`

Thanks so much in advance

Bybreen


// create a 2D array

let cidTwoDArray = [
  ['ONE HUNDRED', 10000],
  ['TWENTY', 2000],
  ['TEN', 1000],
  ['FIVE', 500],
  ['ONE', 100],
  ['QUARTER', 25],
  ['DIME', 10],
  ['NICKEL', 5],
  ['PENNY', 1]
  ];
// sort the array in descending numerical order for clarification

function checkCashRegister(price, cash, cid) {
  let alphaArray = ['ONE HUNDRED', 'TWENTY', 'TEN','FIVE', 'ONE', 'QUARTER', 'DIME', 'NICKEL', 'PENNY']

// use Math.round on the array to round up/down to the nearest whole number

  arrayAlpha.sort();
  console.log(arrayAlpha);

  let alphaOneHundred = 100.00;
  alert(Math.round(alphaOneHundred));

  let alphaTwenty = 20.00;
  alert(Math.round(alphaTwenty));

  let alphaTen = 10.00;
  alert(Math.round(alphaTen));

  let alphaFive = 5.00;
  alert(Math.round(alphaFive));

  let alphaOne = 1.00;
  alert(Math.round(alphaOne));

  let alphaQuarter = 0.25;
  alert(Math.round(alphaQuarter));

  let alphaDime = 0.1;
  alert(Math.round(alphaDime));

  let alphaNickel = 0.05;
  alert(Math.round(alphaNickel));

  let alphaPenny = 0.01;
  alert(Math.round(alphaPenny));

// use if statement to check the status of the cid
if (cash in draw < price) {
return  {status: "INSUFFICIENT_FUNDS", change:[]}

if (cash in draw === price) {
return {status: "CLOSED", change:[]}

if (cash in draw > price) {
  return {status: "OPEN", change:[]}
return change;
}
  // Here is your change, ma'am.
}

// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 100]]

checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

You need to indent your code more consistently to see where, but you are missing two closing curly brackets }. There is definitely one missing which closes the function and another one you will have to find, because it could affect the logic of your solution.

Once you fix that error you will have at least one additional error, because you reference a variable named arrayAlpha but you do not have a variable declared/defined with that name before trying to reference it.

Thanks so much Randell, I’ll give it another go!