# Cash register project12

Tell us what’s happening:
I am trying making an array of change by recursion and try many other methods also
but not able to do
help plz to understand it

var num = 0;
var obj = {
'PENNY':0.01,
'NICKEL':0.05,
'DIME':0.1,
'QUARTER':0.25,
'ONE':1,
'FIVE': 5,
'TEN':10,
'TWENTY':20,
'ONE HUNDRED': 100
}
var arr = [];
function check(change , cid){
if (change === 0)
// break ;
return 1 ;
else{
let l = cid.length-1 ;
var s = [] ;
for (let i= l; i >= 0 ; i--){
if (change > obj[cid[i][0]] && change > cid[i][1] && cid[i][1] > 0){
change = change % cid[i][1] ;
// s = cid[i] ;
cid[i][1] = 0 ;
arr.push(cid[i])
break ;
}else if (change > obj[cid[i][0]]  && change < cid[i][1]){
change = change % obj[cid[i][0]] ;
cid[i][1] = Math.round(change/obj[cid[i][0]])*obj[cid[i][0]] ;
// s = cid[i] ;
arr.push(cid[i]);
break ;
}  } //console.log(change, cid)

return check(change,cid) ;}
}

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

Challenge: Cash Register

Not sure what you’re trying to accomplish here if I’m being honest. In your snippet of code, you’ve got function check which is declared but never called, and a few unused variables. None of the tests pass at all.

Also, in general, it’s bad practice to continue using var. If you need to access a variable in a global scope, declare with const or let where you need it to be accessible.

Try doing this challenge without recursion. Recursion is always tricky to work with. Once you have an actual method on how to find the answer for the challenge you can work that into using recursion, but until you know exactly what you need to do, using recursion and trying to solve the puzzle at the same time is just extra work you have to do.

I have tried most of the simple ways to solve it but can’t able to solve it,
I try recursion which is confusing and not working , I am unable to find a base condition
could you suggest me some ideas and trick to solve it , please

forget the code for a moment. How would you calculate the change to give with pen and paper?

once you know the answer to that question with as many details as possible, then it’s much easier to translate it to code

I have a problem in converting change money cash in exchange value from an array
because we have to check every time we check to the takeout single currency
help me in thinking about how to convert given array to change currency array

And try to complete JS curriculum, if you haven’t already. I think you need bit more experience with JavaScript data structure.

I have submitted improve code but it is showing some unexpected result