You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi ! thank you very much for you amazing tutorials !
Here is my solution for the coins
function getChange (totalPayable, cashPaid) {
var result = [];
var coins = [200, 100, 50, 20, 10, 5, 2, 1];
var diffrence = cashPaid - totalPayable;
var i = 0;
do {
if (coins[i] <= diffrence)
{
result.push(coins[i]);
diffrence = diffrence - coins[i];
}
else
i++;
}
while (i < coins.length);
return result;
}
The text was updated successfully, but these errors were encountered:
BackPackerDz
changed the title
Alerternative solution for coins !
Alternative solution for coins !
Jun 24, 2017
Hi ! thank you very much for you amazing tutorials !
Here is my solution for the coins
The text was updated successfully, but these errors were encountered: