# Cash Register Problem in javascript data structures

Hello all.

My question is less for how to “solve” the problem, and more how to get my program to work since I’m using a simple concept I should have down by now: recursion. So far my program DOES return a Boolean apparently(my console.log() doesn’t work anymore) as the site gave me the check mark. But it doesn’t return any other answers that I would want, even the simple “Insufficient” type answers.Here it is.
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register
Has anyone else had this continuing issue with their console.log()? I’ve heard it might be my browser? I use google chrome.
THANKS A TON!

``````//cid is cash in drawer, price and cash are self explanatory price of object and cash customer is giving.
function checkCashRegister(price, cash, cid) {
var change = (cash - price);

//making my array to define monetary values.
var monArr = [["One Hundred", 100],["Twenty", 20],["Ten", 10],["Five", 5],["One", 1],["Quarter", 0.25],["Dime", 0.10],["Nickel", 0.05],["Penny", 0.01]]

//short is where I'll be storing my values I add up from monArr values
var short = []

if (cid > (cash - price)){
var hen = function Chenel(change){
var i = 0
if (change > monArr[i]){
var fac = change/monArr[i]
change = change%monArr[i]
var num = monArr[i];
short = short.push([monArr[i], fac*num])
i++
return Chenel(change)}
//hen is the variable I'm calling for this function Im making.
//setting i as something I can iterate through my money array with.
//fac is going to be my factor I multiply each denomination of money by so its division basically
//after I have my factor of denomination for bigger denomination find remainder and update that to  be change value. update my overall short array that stores {denomination, how much}
increase i thus decreasing monetary denomination one.. then call Chenel function on new change? or hen(change)? This is recursion right? Is it really out of place?  Thanks
````````````````````````````````````````````````
}
}
//if we dont have the cash in drawer we dont have the change. change is empty array but still not //sufficient?
if (cid < (change)){
return {status: "INSUFFICIENT_FUNDS", change: []}
}

//if cash in drawer is equal to change then we give them the whole drawer  so can I just call my //function I made with cid as argument? I'd be stoked if I made a function and then used it so I dont //know if thats possible here but I've seen it a lot.
if (cid == change){
return Chenel(cid)
return {status: "CLOSED", change: short}
}

//both return my short array I created in the function.
else (cid > (cash - price))
return {status: "OPEN", change: short}
}
``````

// Example cash-in-drawer array:
// [[“PENNY”, 1.01],
// [“NICKEL”, 2.05],
// [“DIME”, 3.1],
// [“QUARTER”, 4.25],
// [“ONE”, 90],
// [“FIVE”, 55],
// [“TEN”, 20],
// [“TWENTY”, 60],
// [“ONE HUNDRED”, 100]]

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]]);

// Example cash-in-drawer array:
// [[“PENNY”, 1.01],
// [“NICKEL”, 2.05],
// [“DIME”, 3.1],
// [“QUARTER”, 4.25],
// [“ONE”, 90],
// [“FIVE”, 55],
// [“TEN”, 20],
// [“TWENTY”, 60],
// [“ONE HUNDRED”, 100]]

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]]);