Skip to content

Instantly share code, notes, and snippets.

@JacksonRMC
Created April 27, 2017 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacksonRMC/dbafc75c5d5b3956b6ea5c72f8ba7a6d to your computer and use it in GitHub Desktop.
Save JacksonRMC/dbafc75c5d5b3956b6ea5c72f8ba7a6d to your computer and use it in GitHub Desktop.
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