Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Glasgow_6 - HERISH TURKI - JS -Core-1-Coursework-Week2 #442

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

HereshT
Copy link

@HereshT HereshT commented Mar 1, 2023

Glasgow_6 - HERISH TURKI - JS -Core-1-Coursework-Week2

Copy link
Member

@SallyMcGrath SallyMcGrath left a 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) {
Copy link
Member

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) {
Copy link
Member

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;
// }
// }
Copy link
Member

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?

Copy link
Author

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) {
Copy link
Member

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! ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants