Skip to content

Instantly share code, notes, and snippets.

@Sara3
Created June 15, 2017 17:03
Show Gist options
  • Save Sara3/8bcf9a45a3d693458bd614f35705e957 to your computer and use it in GitHub Desktop.
Save Sara3/8bcf9a45a3d693458bd614f35705e957 to your computer and use it in GitHub Desktop.
class CashAmount{
constructor(amount) {
this.amount = amount;
this.pennies = this.amount * 100;
}
addDoubleAmount (newAdd) {
this.amount += newAdd;
this.pennies += newAdd*100;
}
toPennies () {
return this.pennies;
}
toDouble() {
return this.amount;
}
toDoubleString() {
return this.amount.toString();
}
quantityOfEachDenomination() {
var den = {};
this.pennies % 100;
}
};
const cash = new CashAmount(0.10);
cash.addDoubleAmount(0.20);
cash.toPennies();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment