LONDON9-LOVELACE-BOSHRA-MAHMOUDI-JS1-WEEK1 - #426
Conversation
| @@ -1,3 +1,5 @@ | |||
| // Start by creating a variable `greeting` | |||
|
|
|||
| var greeting = "I am BOshra"; | |||
There was a problem hiding this comment.
Hi there @BoshraM,
We've just updated our coursework with a change to the variable declarations.
From now on when you're writing variable declarations be sure to use let / const over var.
| var greeting = "I am BOshra"; | |
| const greeting = "I am BOshra"; |
|
|
||
| let greeting = "My name is"; | ||
| let myName = "Boshra"; | ||
| let message = greeting + " " + myName; |
There was a problem hiding this comment.
This looks good.
How else do you think you can improve the RHS ( Right Hand Side ) on line 4 though? You're currently using + to concatenate the strings together - but what other techniques can you use for forming strings using variables. Try checking out template literals and see if you can refactor your code :)
| var numberOfMentors = 8; | ||
| let totalNumber = numberOfMentors + numberOfStudents; | ||
| let percentageOfStudents = (numberOfStudents / totalNumber) * 100; | ||
| let roughPercentageOfStudents = Math.round(percentageOfStudents); |
There was a problem hiding this comment.
Why did you decide to call this variable roughPercentageOfStudents in this case - what makes it rough?
|
|
||
| console.log(greeting); | ||
|
|
||
| var greeting = createGreeting("Boshra"); |
There was a problem hiding this comment.
👓 Watch out for var here, again!
| } | ||
|
|
||
| function greeting(mentor) { | ||
| return `HELLO ${upperCaseName(mentor)}`; |
There was a problem hiding this comment.
Nice use of template literals here! 😄
| function addTaxAndFormatCurrency() {} | ||
|
|
||
| function addTaxAndFormatCurrency(price) { | ||
| return `£${calculateSalesTax(price).toFixed(2)}`; |
There was a problem hiding this comment.
Possibly think about adding another variable in here to make the final return value a bit more readable.
Which part of the expression calculateSalesTax(price).toFixed(2) could you lift out of the template literal and give a meaningful name to ?
| function convertToBRL() {} | ||
|
|
||
| function convertToBRL(price) { | ||
| let newPrice = price * 0.99 * 5.7; |
There was a problem hiding this comment.
This solution looks good to me - I like your use of multiplication by 0.99 to reduce the original value by 1%. 😎
Think about this function for a moment from the perspective of somebody who perhaps is a bit less familiar.
They probably won't have much idea of what the 5.7 means.
Could you assign 5.7 to a variable with a clear name showing what it represents ?
There was a problem hiding this comment.
Hi @BoshraM,
Good job on completing your first piece of JS coursework at CYF! 🎉
I'm seeing lots of good solutions in your coursework so far, so keep up the effort. I think my main piece of feedback would be to think about using some extra variables to store parts of the more complex expressions in your functions. Using variables like this will improve the readability of your code from day 1.
Nice work! 👍
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?
What did you find hard?
What do you still not understand?
Any other notes?