London Class_8 - Deago Browne - JS - Week_1 - #244
Conversation
RitaGlushkova
left a comment
There was a problem hiding this comment.
Hi Deago, as part of our assignment I decided to review your code. I hope you don't mind. Great work! I like how you assign all functions' calls to variables. In my view, it is a very good practice. An overall note would be about using let or const instead of var.
I think if we developed this practice from the beginning we are less likely to cause bugs in the future. Var allows people to completely overwrite it, not just assign a new value. That's why when working in a team, it will be less risky to use let or const.
|
|
||
|
|
||
| function addTaxAndFormatCurrency(x) { | ||
| return (x + 0.20*x).toFixed(2); |
There was a problem hiding this comment.
Hi Deago, well done for fixing it. If you want to add a pound sign, think of it as a "string" that you add with + in your return formula.
There was a problem hiding this comment.
It can be rewritten like this:
return (1.2 * x).toFixed(2);
| // Add comments to explain what this function does. You're meant to use Google! | ||
| function getRandomNumber() { | ||
| return Math.random() * 10; | ||
| // returns a random number between 1 <1, then multiplies that number by 10 |
There was a problem hiding this comment.
Hi Deago, I think there is a typo. Did you mean from 0 to < 1?
| function getStringLength(word) { | ||
| return "word".length(); | ||
| var sentence = "A wild sentence appeared!"; | ||
| var word = "Turtles"; |
There was a problem hiding this comment.
Your variable is declared correctly. I would recommend using let instead. Because if you work with someone else on a very big piece of code, another person might come up with the same variable name word and without knowing rewrite yours. It will then can then cause a problem.
| function multiply(a, b, c) { | ||
| a * b * c; | ||
| return; | ||
| return a * b * c;; |
mahsa2
left a comment
There was a problem hiding this comment.
Well done on finishing the assignment 💯 👏
| @@ -1,3 +1,5 @@ | |||
| // Start by creating a variable `message` | |||
| var myName = "Deago"; | |||
| var nameLength =`My name is Deago, and my name is ${myName.length} characters long`; | |||
There was a problem hiding this comment.
Great use of concatinating string here ⭐
- Also you can use this to add your name.
var->const(orletif the value changes)
const nameLength = `My name is ${myName}, and my name is ${myName.length} characters long`;
|
|
||
| const name = " Deago "; | ||
| nameLength = name.length | ||
| var message = `My name is ${name.trim()} and my name is ${name.trim().length} characters long` |
There was a problem hiding this comment.
You could store the name.trim() in the variable:
let name = " Deago ";
name = name.trim();
nameLength = name.length;
| @@ -1,7 +1,7 @@ | |||
| function halve(number) { | |||
| // complete the function here | |||
| return number / 2 | |||
| } | ||
|
|
||
| var result = halve(12); | ||
| var result = halve(512); |
| @@ -1,5 +1,5 @@ | |||
| function triple(number) { | |||
| // complete function here | |||
| return number * 3 | |||
| @@ -1,4 +1,8 @@ | |||
| // Write your function here | |||
| function createGreeting (a) { | |||
| return "Hello, my name is " + a | |||
There was a problem hiding this comment.
It's better to use this format in general.
return `Hello, my name is ${a}`;
| return b.toUpperCase(); | ||
| } | ||
|
|
||
| function message (b) { |
|
|
||
| function introduceMe(name, age) | ||
| return "Hello, my name is " + name "and I am " age + "years old"; | ||
| var name = "Sonjide"; |
| } | ||
|
|
||
| function concatenate(firstWord, secondWord, thirdWord) { | ||
|
|
There was a problem hiding this comment.
No new line needed at the begining of the function.
|
|
||
|
|
||
| function addTaxAndFormatCurrency(x) { | ||
| return (x + 0.20*x).toFixed(2); |
There was a problem hiding this comment.
It can be rewritten like this:
return (1.2 * x).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? Most of the early exercises, and most of the npm Tests
What did you find hard? Percentages - though I managed to get it done, and I also found some formulas to use in the future
What do you still not understand? Couldn't add the "£" to the Tax function - gave up, as it was time-consuming, and I have other assignments to complete
Any other notes?
View rendered exercises/B-hello-world/README.md