Created
April 27, 2017 16:59
-
-
Save JacksonRMC/dbafc75c5d5b3956b6ea5c72f8ba7a6d to your computer and use it in GitHub Desktop.
This file contains 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
var CashAmount = (amount) => { | |
this.amount = amount.toFixed(2); | |
} | |
CashAmount.prototype.totalInPennies = function() { | |
var amountInPennies = this.amount.toString().split(""); | |
amountInPennies.splice(-3,1); | |
return parseInt(amountInPennies.join("")); | |
} | |
CashAmount.prototype.addDoubleAmount = function(value) { | |
var y = (this.amount.totalInPennies() + value); | |
this.amount = y; | |
} | |
CashAmount.prototype.quantityOfEachDenomination = function() { | |
var demoninations = { | |
hundres: 10000, | |
fifties: 5000, | |
twenties: 2000, | |
tens: 1000, | |
fives: 500, | |
ones: 100, | |
quarters: 25, | |
dimes: 10, | |
nickels: 5, | |
pennies: 1 | |
} | |
var demoninationCount = this.amount.totalInPennies(); | |
while ( demoninationCount > 0 ) { | |
for( var key in demoninations ) { | |
if(demoninations[key] / ) | |
} | |
} | |
} | |
CashAmount.prototype.toDouble = function() { | |
return this.amount; | |
} | |
CashAmount.prototype.toDoubleString = function() { | |
return this.amount.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment