function change(cash) {
console.log('Called for ' + cash)
result = null;
if(cash == 0) {
return {'two':0, 'five':0, 'ten':0}
}
if(cash < 0) {
return null;
}
if(cash >= 10) {
subResult = change(cash - 10);
if(subResult != null) {
result = subResult;
result['ten'] += 1;
return result;
}
}
if(cash >= 5) {
subResult = change(cash - 5);
if(subResult != null) {
result = subResult;
result['five'] += 1;
return result;
}
}
if(cash >= 2) {
subResult = change(cash - 2);
if(subResult != null) {
result = subResult;
result['two'] += 1;
return result;
}
}
return result;
}
console.log(change(42))
let me know if any issues. Thanks!
Do this in JavaScript Please! Question 14/14-Javascript ( 3751 Answer Eve hark sn than thenumber of...