Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Week3 patrick #71

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
struggling with Week1/InClass/D-methods/exercise-5.js
I have tried different ways to include the £ amount eg. this.cappuccino OR this.price.cappuccino OR this.coffee Not sure if I'm getting closer or further from the solution.
  • Loading branch information
wonder woman committed Jul 14, 2020
commit 19ddba950d67193c013f3361f6abd5e342a58f4f
21 changes: 17 additions & 4 deletions Week-1/InClass/D-methods/exercise-5.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@ let coffeeMachine = {
return insertedAmount = amount;
},
getCoffee: function (coffee) {
let prices = coffee;
if (insertedAmount >= 3) {
// check coffee entered matches the correct amount
// if true, return Please take your coffee
// if false, return Sorry
if (insertedAmount >= 3 && coffee === "flatWhite") {
return `Please take your ${coffee}`;
} else if (insertedAmount >= 2.4) {
} else if (insertedAmount < 3 && coffee === "flatWhite") {
return `Sorry you don't have enough money for a ${coffee}`;


} else if (insertedAmount >= 2.4 && coffee === "cappuccino") {
return `Please take your ${coffee}`;
} else if (insertedAmount >= 1.5) {
} else if (insertedAmount < 2.4 && coffee === "cappuccino") {
return `Sorry you don't have enough money for a ${coffee}`;


} else if (insertedAmount >= 1.5 && coffee === "blackCoffee") {
return `Please take your ${coffee}`;
} else if (insertedAmount < 1.5 && coffee === "blackCoffee") {
return `Sorry you don't have enough money for a ${coffee}`;
}
}
};

Expand Down