-
I’d suggest wrapping your
toFixed
calls inNumber()
so you are not using strings. -
The algorithm is working it is just the way you use the
makeChange
function. Try calling and capturing the return one time and use it for the if statement and return value.
if (changeDue < drawerBalance) {
let changeBack = makeChange(cid, changeDue);
if (changeBack == false) {
return { status: 'INSUFFICIENT_FUNDS', change: [] };
} else {
return { status: 'OPEN', change: changeBack };
}
}