function f(money, coins){
return (
// base cases
(money < 0 || coins.length == 0) ? 0 :
money === 0 ? 1 :
// recursive case
f(money-coins[0], coins) + f(money, coins.slice(1))
)
}
[
f(4, [1,2]), // 3
f(10, [5,3,2]), // 4
f(11, [5,7]), // 0
f(0, [5,7]), // 1
].forEach(x => log(x));