-
-
Notifications
You must be signed in to change notification settings - Fork 475
London10 - Khalil Alhaydr - JavaScript-core1-courswork-week1 #493
base: master
Are you sure you want to change the base?
Changes from all commits
4f9765a
48a27ad
2188c2e
2de9ce4
6390277
6db0b59
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,16 +1,16 @@ | ||
| // The syntax for these functions is valid but there are some errors, find them and fix them | ||
|
|
||
| function trimWord(word) { | ||
| return wordtrim(); | ||
| return word.trim(); | ||
| } | ||
|
|
||
| function getStringLength(word) { | ||
| return "word".length(); | ||
| return word.length; | ||
| } | ||
|
|
||
| function multiply(a, b, c) { | ||
| a * b * c; | ||
| return; | ||
| total = a * b * c; | ||
| return total; | ||
|
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. Consider: function multiply(a, b, c) { |
||
| } | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,19 @@ | ||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| // this function return a random number between 0 and 100. | ||
| function getRandomNumber() { | ||
| return Math.random() * 10; | ||
| } | ||
|
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. Clear and good answer |
||
|
|
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| // the concat() method join 2 strings together. | ||
| function combine2Words(word1, word2) { | ||
| return word1.concat(word2); | ||
| } | ||
|
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. Good answer |
||
|
|
||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as me |
||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,11 @@ | |
| Sales tax is 20% of the price of the product. | ||
| */ | ||
|
|
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(price) { | ||
| return price + price*0.2; | ||
|
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. Minor things to suggest. Please keep spacing consistent.You did it for +, but * needs space. 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. Change to this option? |
||
|
|
||
|
|
||
| } | ||
|
|
||
| /* | ||
| CURRENCY FORMATTING | ||
|
|
@@ -17,7 +21,13 @@ function calculateSalesTax() {} | |
| Remember that the prices must include the sales tax (hint: you already wrote a function for this!) | ||
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(price) { | ||
| console.log(price) | ||
| return "£" + calculateSalesTax(price).toFixed(2); | ||
|
|
||
| } | ||
| console.log(addTaxAndFormatCurrency(40)) | ||
|
|
||
|
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. Consider this option. function addTaxAndFormatCurrency(sales) { |
||
|
|
||
| /* | ||
| =================================================== | ||
|
|
||
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.
Comment: On these first three code assignments we have the same solution