var arr = [100,25,5,1];
function decomposite (a) {
var decompositeArray = [];
arr.forEach((item, i) => {
if (!decompositeArray[i]) {
decompositeArray[i] = 0;
}
while (a >= item) {
a -= item;
decompositeArray[i] += 1;
}
});
return decompositeArray;
}
decomposite(132);
[1, 1, 1, 2]
decomposite(300);
[3, 0, 0, 0]