Created
December 29, 2019 03:35
-
-
Save risingBirdSong/de7d392a9c5964d3ccf42d4307e4aad8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coinCombo = function(cents : number) { | |
let change : [penny, nickel, dime, quarter] = [0,0,0,0]; | |
let quarters, dimes, nickels, pennies; | |
if (cents / 25 >= 1) { | |
quarters = Math.floor(cents / 25); | |
cents -= 25 * quarters; | |
} | |
if (cents / 10 >= 1) { | |
dimes = Math.floor(cents / 10) | |
cents -= 10 * dimes; | |
} | |
if (cents / 5 >= 1) { | |
nickels = Math.floor(cents / 5); | |
cents -= 5 * nickels; | |
} | |
return [cents || 0, nickels || 0, dimes || 0, quarters] | |
} | |
coinCombo(56) //? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment