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 Object-Oriented JavaScript (2015) Practice Project Quiz Prototype

Order of prototypes

This is more of an observation rather than a question. I am sure it's subjective, but I feel Quiz.prototype.getCurrentQuestion should be stated before Quiz.prototype.guess.

I feel it's more of a chronoligical order and tells the story better. Also getCurrentQuestion is used within the guess prototype, so if we read code from top to bottom, we know where it's coming from instead of having to search for it, especially if reviewing your code several months later.

It took me a while to figure out that getCurrentQuestion was defined later in the code. This is a small project so it didn't take me a huge amount of time, but it did take extra time. In a larger project it would take even longer.

Am I wrong in my thinking? Or is there a reason it was declared after instead of before? I look forward to hearing other thoughts and opinions?

1 Answer

ludopuig
seal-mask
.a{fill-rule:evenodd;}techdegree
ludopuig
Full Stack JavaScript Techdegree Student 6,436 Points

Hi!

I think you are right, I also read it better your way but it depends also on programming style or even style guides inside organizations... at the end, we will sometimes find it one way, and sometimes the other, and yet other times in a complete other way we can't figure out now!