Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review of exercise Basic JS 3 - Practice conditionals with True or False #1

Open
3 tasks done
carmen-tm opened this issue Feb 18, 2023 · 3 comments
Open
3 tasks done

Comments

@carmen-tm
Copy link

carmen-tm commented Feb 18, 2023

Hi Arman,
I have the chance to quickly review this exercise, and in general is all great. Just some remarks:

  • I would advice you that you take your time to name your variables and functions with a good and descriptive name. It’s a best practice to use camelCase (as you have done) and actually tell what the function is doing by giving the function name a verb as prefix. So instead of myFunction, what about something like checkResponses or something like that, a bit more informative :)
  • That function doesn't need a parameter, so you can remove it. You have put a "R" parameter but you never use it (see you invocation of the function myFunction();, you don't need anything. So remove it from the definition as well.
  • Review your if else statements. They work (well done!!), but you have some unnecessary code there. Some documentation here. In this case with just 2 possibilities (either is true or false), you don't need to use and else if (that is useful when having more than 2 scenarios). But you just have 2: this or that. So a super simple if and else pattern is all you need. With that pattern, the second else block will execute if the first if condition is false, so you don't need to write the condition again making it the opposite. With a simple else, is already defined.

I'll try to explain myself better. You have done something similar to this:

if(condition === true) {
// Run this code
} else if (condition !==true) {
// Run this instead
}

It works, and that's great. But let's try to be more efficient with our code, avoiding redundant things. The block below is exactly the same as this one:

if(condition === true) {
// Run this code
} else {
// Run this instead
}

I hope I'm explaining myself clear enough 🙏🏻, and sorry if not! Let me know if you understand all this, and try to improve your code in that sense. If this is not clear enough, let me know and we can discuss it more via Slack of jitsy until is clear :)
Well done, Arman!! 💪🏻

@mphello
Copy link
Owner

mphello commented Feb 19, 2023

Many thanks, Carmen,

I appreciate your assistance; your feedback has greatly helped me in understanding what I am doing in my codes.
I've made all of the suggested changes. It has now been updated with the new ones. I hope that works.

The repository's GitHub page: https://armanpartovi.github.io/Exercise-Basic-JS-3---Practice-conditionals-with-True-or-false/
repo on GitHub: https://github.com/armanpartovi/Exercise-Basic-JS-3---Practice-conditionals-with-True-or-false

Plus the fact that your explanation was clear enough. thank you.

Best Regards
Arman Partovifar

@carmen-tm
Copy link
Author

Thank you for your kind words, Arman :)

Your exercise is perfffect :) Well done for all the effort and fast improvements your are doing!! 💪🏻💪🏻
giphy (2)

@mphello
Copy link
Owner

mphello commented Feb 19, 2023

Glad to hear that.
thank you.

Regards
Arman Partovi

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

No branches or pull requests

2 participants