NW5-Manchester-Mustafa Acar-JavaScript-Core-1-Coursework-Week1#379
NW5-Manchester-Mustafa Acar-JavaScript-Core-1-Coursework-Week1#379MustafaAcar-sys wants to merge 2 commits intoCodeYourFuture:masterfrom
Conversation
|
Done except extra tasks |
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(productPrice) { | ||
| return "£" + calculateSalesTax(productPrice).toFixed(2); | ||
| } |
There was a problem hiding this comment.
Hi Mustafa I checked your code nice job all of tests has passsed. I like to use this method for getting decimal points that we need.
Dominic-Taylor-Dev
left a comment
There was a problem hiding this comment.
Overall you did a great job here! Just a few comments for the future. The most important one in my opinion is to make sure you use let and const appropriately.
| function addNumbers(a, b, c) { | ||
| return a + b + c; | ||
| } | ||
|
|
||
| function introduceMe(name, age) | ||
| return "Hello, my name is " + name "and I am " age + "years old"; | ||
| function introduceMe(name, age){ | ||
| return "Hello, my name is " + name +" and I am " + age + " years old"; | ||
| } | ||
|
|
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| total = a + b; | ||
|
|
||
| return "The total is total"; | ||
| return "The total is "+ total; |
| return word.trim(); | ||
| } | ||
|
|
||
| function getStringLength(word) { | ||
| return "word".length(); | ||
| return word.length; | ||
| } | ||
|
|
||
| function multiply(a, b, c) { | ||
| a * b * c; | ||
| return; | ||
| return a * b * c; | ||
| } |
| @@ -9,6 +9,8 @@ function combine2Words(word1, word2) { | |||
| } | |||
There was a problem hiding this comment.
Could you add comments to explain the two functions above please?
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
|
|
||
| return firstWord.concat(" ", secondWord, " ", thirdWord); |
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(productPrice) { | ||
| let productTax = (productPrice*20) / 100 + productPrice; |
There was a problem hiding this comment.
Don't forget to indent. If you set up prettier and 'format on save' correctly, then this should happen automatically: https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1/tree/master/exercises/A-setup-ide
Let me know if you need any help with that
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(productPrice) { | ||
| let productTax = (productPrice*20) / 100 + productPrice; |
There was a problem hiding this comment.
I'm not sure if you were introduced to let vs const yet. This is a variable that doesn't need to change, so you'd be better off using const. See here: https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75#:~:text=%60const%60%20is%20a%20signal%20that,always%20the%20entire%20containing%20function.
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(productPrice) { | ||
| let productTax = (productPrice*20) / 100 + productPrice; |
There was a problem hiding this comment.
This is more of an advanced comment, but it's usually bad to have 'magic numbers' in code i.e. any numbers that don't have an obvious meaning. So I'd advise using an extra line to explain that the 20 is the tax rate (the 100 is okay because it's obvious in the code that you're using it to make a percentage):
function calculateSalesTax(originalPrice) {
const taxRate = 20;
const taxOnOriginal = originalPrice * (taxRate / 100);
return originalPrice + taxOnOriginal;
}
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(productPrice) { | ||
| return "£" + calculateSalesTax(productPrice).toFixed(2); |
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?
creating variables
What did you find hard?
Nested functions
What do you still not understand?
Any other notes?
@Dominic-Taylor-Dev