-
-
Notifications
You must be signed in to change notification settings - Fork 438
Glasgow_6 - HERISH TURKI - JS -Core-1-Coursework-Week2 #442
base: main
Are you sure you want to change the base?
Conversation
Glasgow_6- Herish - Turki - JS - Core-1-Coursework-Week2
Glasgow_6 - HERISH TURKI - JS -Core-1-Coursework-Week2
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.
Lovely work @HereshT . Thanks for your hard work and effort here. I've dropped a few comments and asked a few questions. Take a look and have a think.
|
||
if (isHappy) { | ||
function getMood(isHappy) { | ||
if (isHappy === true) { |
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.
This works and is a good answer.
It might be interesting now to explore ways to refactor and simply this function.
if (isHappy === true)
If isHappy is the same as true, do you need to make this check? What does isHappy evaluate to? (Replace the left hand side with the value of isHappy and read the code again. )
@@ -4,7 +4,9 @@ | |||
1. the user should be 18 or older | |||
2. the user must be logged in | |||
*/ | |||
function isAcceptableUser(userAge, isLoggedIn) {} | |||
function isAcceptableUser(userAge, isLoggedIn) { |
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.
Another great answer.
How might you refactor this? Try writing this function a few different ways and thinking about it (this is also fun to do in Codewars).
// } else { | ||
// return totalPrice * 0.95; | ||
// } | ||
// } |
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.
Fab. I definitely prefer the code you chose over the commented out solution. Can you guess why?
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.
Regarding my approach to these tasks, I set aside my coding skills and knowledge and write the possible logical solutions using sudo language. Then, I use code to implement them.
Back to your - why question - I feel that the first solution is the most suitable since it is easy to understand, clear, and allows for the implementation of different discounts if needed.
@@ -45,7 +88,11 @@ function canRegister(age) {} | |||
) | |||
*/ | |||
|
|||
function countReverse(number) {} | |||
function countReverse(number) { |
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.
I like this decrementing solution. I think the example solution uses a while loop, but I prefer yours! ;)
Glasgow_6 - HERISH TURKI - JS -Core-1-Coursework-Week2