Divide the Bonus : <p>I have a list (array) of employees who will be rewarded as follows:</p>

<ul>
<li><p>Const worker = [
<code>{name: "John", prize: 1000, prioritize: 1},</code>
<code>{name: "Andy", prize: 2000, prioritize: 2},</code>
<code>{name: "Bill", prize: 2200, prioritize: 3},</code>
<code>{name: :Carry", prize: 3100, prioritize: 4},</code>
<code>{name: "Asawa", prize: 4000, prioritize: 5}</code>
]; //( array Worker is not fixed ...)</p></li>
<li><p>Let TotalPrize = 7100 // fund bonus</p></li>
</ul>

<p>Problem: I want to subtract TotalPrize for the list above (1-> 2-> 3 ...) so that Workers gets the full prize by order Prioritize:</p>

<ul>
<li>John: 1000 (full)</li>
<li>Andy: 2000 (full)</li>
<li>Bill: 2200 (full)</li>
<li>Carry: 1900 (the list above, Carry must be 3100, but because TotalPrize = 7100 has been divided in advance for the first three remaining 1900)</li>
<li>Asawa: 0 (because all the money for the first 4 people was divided)</li>
</ul>

<p>Who has the solution and helps me to solve the problem, 2 weeks in desperation. So sad</p>
