Skip to content

Instantly share code, notes, and snippets.

@davelnewton
Last active April 24, 2019 09:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davelnewton/74befeb5f89bc6a81d55f9b3471a9238 to your computer and use it in GitHub Desktop.
Save davelnewton/74befeb5f89bc6a81d55f9b3471a9238 to your computer and use it in GitHub Desktop.
Code Cleanup on Aisle 5
const prices = {
"Residential": 90,
"Business": 150,
}
// TODO Handle no price found.
const price = numberOfRooms * prices[propertyUsage]
let discountMultiplier = 0
if (numberOfRooms >= 10) {
discountMultiplier = .15
} else if (numberOfRooms >= 6) {
discountMultiplier = .1
}
discountedPrice = price + (price * discountMultiplier)
discount = !!discountMultiplier ? `(${discountMultiplier*100}%)` : "No Discount Applied"
document.getElementById("tableSub").textContent = `£ ${price.toFixed(2)}`
document.getElementById("tableDiscount").textContent = `£ ${discountedPrice.toFixed(2)} ${discount}`
@mike8724
Copy link

Thank you for your guidance Dave.
I have looked at the above code and when I run it I get an error which refers to the switch statement, Does this need to be declared elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment