Cash Register (Final JS Certification Project)

Tell us what’s happening:
I’m just stuck and seem to head nowhere. Can somebody help me with my bad approach here?

Your code so far


function checkCashRegister(price, cash, cid) {
  
var i,changeGivenBack = 0;

var valueArray = [["PENNY", 0.01],["NICKEL", 0.05],["DIME", 0.1],["QUARTER", 0.25],["ONE", 1],["FIVE", 5],["TEN", 10],["TWENTY", 20],["ONE HUNDRED", 100]];

var totalNotes = [["PENNY", 0],["NICKEL", 0],["DIME", 0],["QUARTER", 0],["ONE", 0],["FIVE", 0],["TEN", 0],["TWENTY", 0],["ONE HUNDRED", 0]];
  
var changeAvailable = 0;
var exactChange = false;
var cf = 100;
var change = cash * cf  - price * cf;
change = change/cf;

for(i=0;i<9;i++){
    totalNotes[i][1] = ((cid[i][1])*cf)/((valueArray[i][1])*cf);
}

console.log(totalNotes);


while(change <= changeAvailable && change !== changeGivenBack )
  {
    while(totalNotes[][1]!==0 || )
    changeGivenBack =+ 
  }
else
  return {status: "INSUFFICIENT_FUNDS", change: []};

}

checkCashRegister(19.5, 20, [["PENNY", 0.11], ["NICKEL", 2], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register/

You may try to use an object like below:

var changeDefn = {
    "PENNY": 0.01,
    "NICKEL": 0.05,
    "DIME": 0.10,
    "QUARTER": 0.25,
    "ONE": 1.0,
    "FIVE": 5.0,
    "TEN": 10.0,
    "TWENTY": 20.0,
    "ONE HUNDRED": 100.0
  };

And then you may loop over the keys of the object in reverse direction as below

Object.keys(changeDefn)
      .reverse()
      .forEach(function(k, i) {
        // your code here

Alright, thanks man, I’ll give this one a try! Cheers.