Skip to content

Instantly share code, notes, and snippets.

@abdalla
Created March 23, 2017 16:56
Show Gist options
  • Save abdalla/c0f5ec0136bca695c08ffc79a5a68fcf to your computer and use it in GitHub Desktop.
Save abdalla/c0f5ec0136bca695c08ffc79a5a68fcf to your computer and use it in GitHub Desktop.
enjoy
const typesOfCoins = [25, 10, 5, 1];
const exchange = vl => {
let exchanges = [];
typesOfCoins.reduce((cur, next) => {
const val = Math.floor(cur/next);
const rest = cur - (val * next);
exchanges.push(val);
return (exchanges, rest);
}, vl);
return exchanges;
}
console.log(exchange(106));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment