Created
October 23, 2020 18:17
-
-
Save wedburst/7ae343115636abae88e1eac988afab19 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
| 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