DEV Community

Discussion on: JavaScript Katas: Coin Combination

Collapse
 
kosich profile image
Kostia Palchyk

This took me a while:

const coinCombo = [25, 10, 5, 1]
  .reduceRight((a, c) => n => [Math.floor(n/c), ...a(n % c)], () => [])

I believe that understanding the solution is part of the fun, so I usually don't add explanation here not to ruin that deduction exercise. Though, I'd be happy to explain/discuss it if someone asks. Is that ok? Michael, what do you think?

Collapse
 
miku86 profile image
miku86

Hey Kostia,

nice solution. Think I never used reduceRight in real life.
Sure, you can do that!