Hi Everyone, I’m pulling out my hair on this one and could use some help.
Just starting this challenge and want to total the CID (cash in drawer). I must be missing something very basic. The numbers are being treated like a string and concatenating instead of adding. WHen I do ‘typeof’ is says its a number.
WHen I look it up I get results relating to a float point issue (that is going to be my next hurdle I think?).
Heres the code:
function checkCashRegister(price, cash, cid) {
var change;
// Here is your change, ma'am.
var total = cid.reduce(function (tot, curr){
tot += curr[1];
console.log(tot);
return tot;
});
console.log(total);
return change;
}
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]]);