-
-
Notifications
You must be signed in to change notification settings - Fork 480
London10-StellaDelMar_RodriguezFernandez-JavaScript-Core-1-Coursework-Week1 #546
base: master
Are you sure you want to change the base?
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,16 +1,17 @@ | ||
| // 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) { | ||
| return a + b + c; | ||
| } | ||
|
|
||
| function introduceMe(name, age) | ||
| 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`; | ||
| } | ||
|
|
||
|
Contributor
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. Small comment on this one - whenever you are declaring a new variable, it's a good idea to use |
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| stella = a + b; | ||
|
|
||
| return "The total is total"; | ||
| return `The total is ${stella}`; | ||
| } | ||
|
|
||
| /* | ||
|
|
||
| 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 | ||
|
|
||
|
Contributor
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. These all look perfect to me 👍 |
||
| 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; | ||
| return a * b * c; | ||
| } | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,11 @@ function getRandomNumber() { | |
|
|
||
|
Contributor
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's worth attempting these if you get some time. |
||
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function combine2Words(word1, word2) { | ||
| console.log(); | ||
| console.log(); | ||
| console.log(); | ||
| return word1.concat(word2); | ||
|
|
||
| } | ||
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ | |
| Sales tax is 20% of the price of the product. | ||
| */ | ||
|
|
||
|
Contributor
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. Great job on these exercises 👍 |
||
| function calculateSalesTax() {} | ||
| function calculateSalesTax(sales) { | ||
| let total = (sales*0.2)+sales; | ||
| return total; | ||
| } | ||
|
|
||
| /* | ||
| 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(price) { | ||
| let num = calculateSalesTax(price); | ||
| return "£" + num.toFixed(2); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| =================================================== | ||
|
|
||
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.
These look good to me 👍