Northwest Class 4 - Humail Khan - JavaScript-Core-1 - Coursework - Week 1 - #115
Northwest Class 4 - Humail Khan - JavaScript-Core-1 - Coursework - Week 1#115humailhasankhan wants to merge 19 commits into
Conversation
… variable three times to the console
…nother variable with its typeof and logging both variables to the console
…ird variable and logged the third variable to the console
…st one and .trim for the second one to use the given variable and count the characters.
…of students and mentors. Finally, created a third variable with template litterals to give a string including the totals
…ncept generally remains the same.
…ages of students and mentors. Logged it to console using Math.round inside of template literals
…nside of the functions to halve and triple the numbers respectively.
…t take numbers and strings as parameters
… inside another function.
…tion 3 where three parameters are concatenated using the + operator.
…on calling first function to give total and returning value in pounds with toFixed at 2 decimals
…ound *1.4, second function used parseFloat to return decimal number value with toFixed at 2 decimals and calculated 99% of total by multiplying by 0.99
…ring badCode variable and two more variables to go along goodCode variable. Added parseFloat toFixed at 1 decimal so it meets the requirements to cater decimal numbers with 1 decimal
…ber for shakeball function and using else if statements for both functions as conditions to pass the tests
| const numberOfMentors = 8; | ||
| const totalNumbers = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log(`Number of students: ${numberOfStudents}`); |
|
|
||
| // Why can this code be seen as bad practice? Comment your answer. | ||
| let badCode = | ||
| let badCode = format(multiply(add(startingValue, 10), 2)); |
There was a problem hiding this comment.
Can you articulate why this code would be bad practice?
There was a problem hiding this comment.
My take on this one was that chaining too many times would be considered as bad practice.
|
|
||
| if (veryPositive.includes(answer)) { | ||
| return "very positive"; | ||
| } else if (positive.includes(answer)) { | ||
| return "positive"; | ||
| } else if (negative.includes(answer)) { | ||
| return "negative"; | ||
| } else if (veryNegative.includes(answer)) { | ||
| return "very negative"; |
There was a problem hiding this comment.
nice - this is a good use case for the array method "includes"
There was a problem hiding this comment.
Thank you Paul. This was refactored with the help of Guardians.
| // 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. | ||
| // We could not use concat() because it only accepts strings. It would not meet all conditions of the test. | ||
| return firstWord + " " + secondWord + " " + thirdWord; |
There was a problem hiding this comment.
How would you explain what happens in this function in order for the last test case to work with a number?
Google "javascript coercion" if you'd like to find out more! We'll see more examples of this throughout the course.
There was a problem hiding this comment.
I would have to look it up. But my guess is that it has to do something with adding numbers and strings together. 13 is a number in the last test and the rest are strings. Probably the typeof would be different and they would be added together but not computed? I will look into javascript coercion. Thanks Paul.
|
Excellent work - well done! You have also used some array methods I see - you'll be seeing more of those in JS 3 so stay tuned :) |
|
Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback. |
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?