JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<div class="form-group">
<label for="myValue">Insert the value</label>
<input type="text" class="form-control" id="amountOfMoney">
</div>
<div class="form-group">
<label for="result">Combination</label>
<input type="text" class="form-control" id="result">
</div>
<button type="button" class="btn btn-default btn-submit">Submit</button>
JavaScript
const ArrayPrimitive = [100,50,20,10];
var combination = [];
$(document).ready(function(){
$(".btn-submit").on("click",function(){
var amountOfMoney = document.getElementById('amountOfMoney').value;
for(let i=0; i=ArrayPrimitive.length;i++){
if(amountOfMoney=ArrayPrimitive[i]){
combination.push(amountOfMoney);
}
while(amountOfMoney > ArrayPrimitive[i]){
var k = amountOfMoney/ArrayPrimitive[i];
for(let j=0; j = k; j++){
combination.push(ArrayPrimitive[i]);
amountOfMoney = amountOfMoney - ArrayPrimitive[i];
}
var rest = n % ArrayPrimitive[i];
}
}
});
});