Last active
April 24, 2019 09:57
-
-
Save davelnewton/74befeb5f89bc6a81d55f9b3471a9238 to your computer and use it in GitHub Desktop.
Code Cleanup on Aisle 5
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
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}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?