its the cash register one
i’m building the ‘change’ array from the ‘cid’ array but need to set the values to zero. just to have the denominations in a 2D array with 0 quantity for each.
function checkCashRegister(price, cash, cid) {
//var change=[["PENNY", 0], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]
var change=cid
console.log('1:',change)
change=cid.map(function(elem){
elem[1]=0
console.log('2:',change)
})
console.log('3:',change)
....
change=( change.filter((elem)=>elem[1]>0) ).reverse()
....
return {status: "OPEN", change: change}
}
console.log(
checkCashRegister(3.26, 100, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]])
)
(i already have a working function but i’m trying to change things and more concerned about learning rather than completing the exercise)