Greetings, I'm looking for a way to add the amount of an input, so many times I tell you in another input. The problem arises that I must take 20% of that amount and add it when I have previously added the amount of the input 3 times. Give an example:
quantity input: 9 input of amount: $ 10,000
First multiplication: 10,000 * 3 = 30,000
Initial amount: 10,000 * 0.2
Second multiplication: 12,000 * 3 = 36,000
Percentage second initial amount: 12,000 * 0.2
Third Multiplication: 14,400 * 3 = 43,200
Total cost: $ 109,200
To be clear, I need you to get the percentage every 3 amounts, like this: 10,000, 10,000, 10,000, 12,000, 12,000, 12,000, 14,400, 14,400, 14,400, and then add all those values, knowing that in the input that you call above, there can be values from 1-50. I'm struggling to develop the algorithm, I do not get the form, who can help me thank you very much. Until now, this is what I'm using:
<script>
var aumento = 0.2;
var aumentaCada = 3;
var cantidad = $("#num").val();
var monto = $("#input7").val();
for(var i=0; i< cantidad ; i++){
if((i>0) && (i % aumentaCada)==0){
monto = monto * (1+aumento);
}
var total = monto * cantidad;
}
$("#total").val(total);
</script>