JSFiddle - React, Tailwind, and code Playground
by vanduzled
JavaScript
const currencyUnit ={
"PENNY": 1,
"NICKEL": 5,
"DIME": 10,
"QUARTER": 25,
"ONE": 100,
"FIVE": 500,
"TEN": 1000,
"TWENTY": 2000,
"ONE HUNDRED": 1000
}
function checkCashRegister(price, cash, cid){
let changeSum = cash * 100 - price * 100;
let changeSumCheck = changeSum;
let change = [];
let status = '';
let cidSum = 0;
let filteredCid = cid.filter(elem => elem[1] !== 0).reverse();
return filteredCid;
filteredCid.forEach(elem => {
let curr = elem[0];
let currSum = elem[1] * 100;
});
}
console.log(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]]));