Not sure if this is an efficient solution but here is mine in JavaScript. I took the liberty to return an object instead of the number of coins and sorted the denominations instead of expecting it in order. I also added the test case suggested by davidmmooney.
Not sure if this is an efficient solution but here is mine in JavaScript. I took the liberty to return an object instead of the number of coins and sorted the denominations instead of expecting it in order. I also added the test case suggested by davidmmooney.
the 'coins3,40' test returns the wrong answer it should be "20: 2"