WM4 - Simeon Bikov - JS - week 1 - #343
Conversation
|
Uau, great work Simeon! As my test didn't even pass, I can't really say much. |
|
Every thing looks perfect. Well done! |
| total = a ++ b; | ||
|
|
||
| return "The total is total"; | ||
| total = a + b; |
There was a problem hiding this comment.
Do you remember what we need to put at the start of the line when defining or creating a new variable?
| @@ -1,16 +1,15 @@ | |||
| // Add comments to explain what this function does. You're meant to use Google! | |||
| // Return a random number between 0 and 10 | |||
There was a problem hiding this comment.
What kind of number? Decimal? Integer? Positive or negative?
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(priceBeforeTax) { | ||
| let priceWithTax = priceBeforeTax * 1.2; |
There was a problem hiding this comment.
This confused me to begin with as to why you were multiplying the price by 1.2. One of the reasons is that I have no idea what the significance of that number is. In the industry we'd refer to this as a "magic number". It's considered better to treat it as a named constant defined somewhere in your code. Some people/organisations will capitalize shared constants, something like:
const TAX_RATE = 0.2;
function calculateSalesTax(price) {
let tax = price * TAX_RATE;
return price + tax;
}
| function convertToBRL() {} | ||
| function convertToBRL(amountGBP) { | ||
| let amountBRL = (amountGBP * 0.99) * 5.7; | ||
| amountBRL = Math.round((amountBRL + Number.EPSILON) * 100) / 100; |
| function shakeBall() { | ||
| //Write your code in here | ||
| let randomNumber = Math.trunc(Math.random() * answers.length); | ||
| let randomAnswer = answers[randomNumber][0]; |
| //Write your code in here | ||
|
|
||
| function checkAnswer(randomAnswer) { | ||
| for (i = 0; i < answers.length; i++) { |
There was a problem hiding this comment.
What keyword do we need to put in front of a new variable?
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?