glasgow class 6-siver omar-javascript 1-week1#548
glasgow class 6-siver omar-javascript 1-week1#548siveromar wants to merge 1 commit intoCodeYourFuture:masterfrom
Conversation
| return `Hello, my {name}` is "and I am $age years old`; | ||
|
|
||
| function introduceMe(name, age){ | ||
| return `Hello, my name is ${name} and I am ${age} years old`; |
There was a problem hiding this comment.
👍 Great job on using string interpolation!
| // There are syntax errors in this code - can you fix it to pass the tests?// | ||
|
|
||
| function addNumbers(a b c) { | ||
| function addNumbers(a ,b ,c) { |
There was a problem hiding this comment.
This looks good!
❓ Have you tried running prettier on your code? The formatting on these commas is a little inconsistent with the rest of the file
| function concatenate(firstWord, secondWord, thirdWord) { | ||
| // Write the body of this function to concatenate three words together. | ||
| // Look at the test case below to understand what this function is expected to return. | ||
| return firstWord.concat(" ", secondWord, " ", thirdWord); |
There was a problem hiding this comment.
👍 Great use of the concat function!
| return Math.random() * 10; | ||
|
|
||
| } | ||
| // It generates a random number using Math.random() and it multiplies by 10 |
There was a problem hiding this comment.
Exactly correct.
❓ Could you perhaps explain what the output of Math.random() is? Did you happen to find any documentation on this to help explain it?
As a heads up - It's usually common to put comments above the code they are describing!
| return word1.concat(word2); | ||
| } | ||
|
|
||
| // the concat() method is used to merge two or more arrays. |
There was a problem hiding this comment.
❓ Is it just arrays that can use the concat() method? Did you come across any useful documentation when investigating?
| } | ||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| total = a + b; |
There was a problem hiding this comment.
This code will work, but we should always use either let or const when declaring a new variable 😅
Do you know why that is?
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(price) { | ||
| let productPriceRes = calculateSalesTax(price); |
There was a problem hiding this comment.
A really hard thing to do is choose variable names - Variable names should make it clear at a glance what is stored in the variable.
Res leaves it a little ambiguous and up to interpretation, partly because it is a shortened word. Perhaps something like productPriceWithTax would be clearer? What do you think?
| function addTaxAndFormatCurrency(price) { | ||
| let productPriceRes = calculateSalesTax(price); | ||
|
|
||
| return `£${productPriceRes.toFixed(2)}`; |
| let salesTax = productPrice * 0.2; | ||
| return productPrice + salesTax |
|
Overall - Great work! These are just a few little things that are worth noting. |
Homework Details