JSFiddle - React, Tailwind, and code Playground

by not important

CoffeeScript

changeFinder = (amount, denominations) ->
    lookup = [1]
    for coin in denominations
        for higherAmount in [coin...(amount + 1)]
            higherAmountRemainder = higherAmount - coin
            lookup[higherAmount] = 0 unless lookup[higherAmount]?
            lookup[higherAmount] += (lookup[higherAmountRemainder] or 0)
    lookup[amount]

console.log changeFinder 30, [1, 5, 10, 25]