ZA2-Shafiek Davids- JavaScript-Core-1-Coursework-Week1 - #304
ZA2-Shafiek Davids- JavaScript-Core-1-Coursework-Week1 #304shafiekdavids wants to merge 1 commit into
Conversation
dschouw-CYF
left a comment
There was a problem hiding this comment.
Awesome work Shafiek. Thanks so much for your submission.
One final suggestion, try and commit your work early and often 💻
| var fullSentence = message + name + sentence + nameLength + sentenceEnd; | ||
|
|
||
| console.log(message); | ||
| console.log(fullSentence); |
There was a problem hiding this comment.
Nice work Shafiek 🔥
Works as expected, but maybe not all the parts of the string needs to be seperate variables.
Using template literals will make the code less cluttered and achieve the same result.
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
|
|
||
| let preciseStudentPercentage = (numberOfStudents / 23) * 100; |
There was a problem hiding this comment.
Works as expected , well done.
As a suggestion, try to avoid magic numbers in your code.
Would the preciseStudentPercentage still be correct if the numberOfStudents or numberOfMentors changes ?
In this scenario, 23 is a "magic number". We know that it works now because that is the total of students + mentors, but what can we do to make it work if those values change?
| @@ -1,5 +1,9 @@ | |||
| // Write your function here | |||
|
|
|||
| function createGreeting(name) { | |||
There was a problem hiding this comment.
| function createGreeting(name) { | |
| function createGreeting(name) { | |
| // function createGreeting should also include the static text "Hello, my name is " |
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
| console.log(greeting); | ||
| function createLongGreeting(name, age) { |
There was a problem hiding this comment.
Modifying the code from exercise3.js in this folder, can you modify createLongGreeting to return a greeting with both the name ( a string ) and an age ( a number ) ?
| @@ -1,5 +1,16 @@ | |||
| var mentor1 = "Daniel"; | |||
| let mentor1 = "Daniel"; | |||
There was a problem hiding this comment.
That's right!! 👍
Avoid var !! Thanks for that update Shafiek
| 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).concat(" ", thirdWord); |
There was a problem hiding this comment.
Nice use of chaining functions, well done
| */ | ||
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(currency) { |
There was a problem hiding this comment.
Using the hint in the comment (hint: you already wrote a function for this!), can you think of another way to calculate the tax in the addTaxAndFormatCurrency function? Remember, functions are written to be reusable and to prevent us from rewriting logic
Commit of exercises
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?
View rendered README.md