Build a Cash Register Project - Build a Cash Register

Tell us what’s happening:

The issue here is not so much the task as an interrupted syntax.I cannot find the unexpected token.

Your code

let price = 1.87;
let purchased = document.getElementById("purchase-btn");
let cash = document.getElementById("cash");
let changeDue = document.getElementById("#change-due");

let cid = [
  ['PENNY', 1.01],
  ['NICKEL', 2.05],
  ['DIME', 3.1],
  ['QUARTER', 4.25],
  ['ONE', 90],
  ['FIVE', 55],
  ['TEN', 20],
  ['TWENTY', 60],
  ['ONE HUNDRED', 100]
];

const cidDue = (cid, cash) => {
  for (let i = 0; i <= cid.length; i++) {
    cid.forEach(price, (cash) => {
      return price - cash
    })
  }
};

const checkPrice = (price, cash) => {
  purchased.addEventListener("click", () => {
    if (cash < price) {
      alert("Customer does not have enough  money to purchase the item")
    };
    if (cash === price) {
      changeDue.value = "No change due -customer paid with exact cash"
    }
    if (cash > price) {
      changeDue.value = `${cidDue}`
    }
  })
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0

Challenge Information:

Build a Cash Register Project - Build a Cash Register

When does the checkPrice() function run?

I do not get an error with your code, can you share what error you are getting exactly?

SyntaxError: unknown: Unexpected token (28:2)

  26 | if(cash===price){changeDue.value="No change due -customer paid with exact cash"}
  27 | if(cash>price){changeDue.value=`${cidDue}`
> 28 |  })
     |   ^
  29 |  
  30 |  };}
  31 |

I’m not seeing that syntax error either! But if blocks should not end in a semi-colon. Try removing that.

As an aside, you seem to be using semi-colons inconsistently. Semi-colons should be used to mark the end of a statement. But they should not be used after curly braces for the following blocks of code: if, while, switch, and for.

if(cash>price){changeDue.value=`${cidDue}`
> 28 |  })
     |   ^
  29 |  
  30 |  };}

You’ve shared two sets of code.

One is WELL FORMATTED and there is no syntax error.

One is NOT WELL FORMATTED and there is a syntax error.

Are you seeing a pattern?

PLEASE STOP asking people to debug your poorly formatted code.