Skip to content

Instantly share code, notes, and snippets.

@wedburst
Created October 23, 2020 18:17
Show Gist options
  • Select an option

  • Save wedburst/7ae343115636abae88e1eac988afab19 to your computer and use it in GitHub Desktop.

Select an option

Save wedburst/7ae343115636abae88e1eac988afab19 to your computer and use it in GitHub Desktop.
function getMilk(money, costPerBottle) {
console.log("move to store to buy milk");
// var numberOfBOttles = Math.floor(money / 1.5);
// console.log("buy " + numberOfBOttles + " bottles of milk");
console.log("buy " + calcBottles(money, costPerBottle) + " bottles of milk");
console.log("go back to home");
// return money % 1.5;
return calcChange(money, costPerBottle);
}
// var change = getMilk(4);
// console.log(change);
function calcBottles(startingMoney, costPerBottle){
var numberOfBOttles = Math.floor(startingMoney / costPerBottle);
return numberOfBOttles;
}
function calcChange(startingAmount, costPerBottle) {
var change = startingAmount % costPerBottle;
return change;
}
console.log("Hello master, here is your " + getMilk(5, 1.5) + " Change.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment