JavaScript Algorithms and Data Structures Projects - Cash Register

Tell us what’s happening:
Describe your issue in detail here.
can,t figure out where i went wrong

   **Your code so far**
function checkCashRegister(price, cash, cid) {
 let change = cash * 100 - price * 100;
 let cid Total = 0
 for (le elem of cid){
cidTotal += elem[1]* 100
 }
 if (change > cidTotal);{

return {status: "INSUFFICIENT_FUNDS", change: []}
 }{else if (change === cid Total)
}return{status: "CLOSED", change:cid}
}else{
 let anwser = []
 cid -cid. reverse ()
 let moneyUnits ={"ONEHUNDRED":10000."TWENTY":2000,"TEN":1000,"FIVE":500,"ONE":100,"QUARTER":25,"DIME":10,"NICKEL":5,"PENNY":1}
 for (let elem of cid){
   let holder = [elem[0],0]
   elem [1] = elem [1] * 100
   while (change >= moneyUnits[elem[0]] && elem [1] > 0){
change -= moneyUnits [elem[0]]
elem [1] -= moneyUnits [elem[0]]
holder [1] += moneyUnits [elem[0]]/100
if (holder [1] >0){anwser.push(holder)
if(change > 0){return{status: "INSUFFCIENT_FUNDS",change:[]}}
   }
   return {status: "OPEN",change: anwser}
 }
}
}
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]]);
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Cash Register

Link to the challenge:

Can you be more specific about what’s going on and where you are stuck?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.