-
-
Notifications
You must be signed in to change notification settings - Fork 475
London Class 7 - Benyam Worku - Javascript-Core - Week 1 #71
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function getNumber() { | ||
| // generates random floating numbers between zero and 10 but never 10 | ||
| return Math.random() * 10; | ||
| } | ||
|
|
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function s(w1, w2) { | ||
| // stringing together two strings-no spaces- and returns a string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A better way of commenting is: join two strings with no spaces
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay thanks |
||
| return w1.concat(w2); | ||
| } | ||
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
| return firstWord + " ".concat(secondWord) + " ".concat(thirdWord); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works perfectly well, but I would advise you to use one method of concatenating. In this line, you use both the plus sign + and the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure will do thanks . |
||
| // 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. | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ | |
| Sales tax is 20% of the price of the product | ||
| */ | ||
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(prices) { | ||
| // the sales tax is 20% of the prices | ||
| return 0.2 * prices; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that the test has failed. Would you be able to fix this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has it ? It passed on my machine . I will apply toFixed(2) |
||
| } | ||
|
|
||
| /* | ||
| CURRENCY FORMATTING | ||
|
|
@@ -17,7 +20,11 @@ function calculateSalesTax() {} | |
| Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(prices) { | ||
| // this function adds on the 20% tax to the original price | ||
| let afterTax = prices + calculateSalesTax(prices); | ||
| return `£${afterTax}` | ||
| } | ||
|
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might need to use .toFixed(2) to force it to give two decimals
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that is a good idea. But , this passed the test too. I guess it is because we've multiplied it by 0.2 . I will look into it. Thanks ! |
||
|
|
||
| /* | ||
| =================================================== | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small note here. Please ensure that the indentation is correctly done (especially the brackets). It should be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier has been working fine . I will have a look. Thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can refer to https://syllabus.codeyourfuture.io/guides/code-style-guide