Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Justin Bibler
Justin Bibler
1,390 Points

I organized my code quite differently...

The end result I got was the same, but that is not always enough. I organized my code to perform each task of each logical grouping and then move on to the next task, e.g. I asked all questions first, then incremented the totalCorrect variable, then my conditional comparisons, etc. Is there an intrinsic reason to have done it the way it was done in the video, e.g. resource consumption, etc?

1 Answer

Hi Justin,

Readability of the code is the main reason for organizing it. How it is organized doesn't really impact consumption or performance. Each language has best practices followed by that community of developers and your job may want you to follow them.

Some programmers don't bother with best practices because they say the computer doesn't care what the code looks like to run and it is only for a programmers benefit.

Many programmers strive to write "Clean Code" that is organized for maximum readability, understanding and elegance in coding the solution. There are a number of good books and web articles on writing clean code.

Happy coding...Edward

Justin Bibler
Justin Bibler
1,390 Points

It occurred to me only this morning as I settled into begin studying that I never thanked you for your response. You took the time to write me a thoughtful and informative answer to my question and I appreciate it! Thank you!

Justin