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 trialsibal gesekki
3,484 Pointsthis is my code to the challenge but i dont think its what the instructor wanted...feedback to my code is appreciated :D
so the instructor gave us 4 js files. one for the questions, one for the quiz, one for the quiz UI, and one for the main programming to bring everything together.
this course focused on using prototypes and inheritance but i couldnt really see how they were necessary (i havent viewed the instructors solution yet). i used 2 prototypes but no inheritance. so in the snapshot below, you can see that i left two of the js files blank. i focused everything heavily in the app.js file
id love any feedback. thanksss
1 Answer
Damien Watson
27,419 PointsHi, the course teaches prototypes and inheritance but also how to group your code together logically. Where slapping all javascript into one file 'might' seem easy and work ok for this example, once you get into larger projects where there is a larger code base or a team of developers you will get lost.
You will find in coding there are many ways of achieving the same goal, a lot of examples in Treehouse teach you concepts and best practices and the focus is on the goal of the lesson, not necessarily how optimised you can make it.
An example is when assigning the questions. In your code you have:
var questions = [];
var q1 = new Question('What is the color of the sky?', 'blue', 'green');
var q2 = new Question('What is essential to humans?', 'water', 'chocolate');
var q3 = new Question('What do we do at night?', 'Sleep', 'Eat lunch');
questions.push(q1, q2, q3);
Where you could achieve this with less code, the code above lays it out clean and simple. Something like the following may raise more answers.
var questions = [
new Question('What is the color of the sky?', 'blue', 'green'),
new Question('What is essential to humans?', 'water', 'chocolate'),
new Question('What do we do at night?', 'Sleep', 'Eat lunch')
];
Hope this helps. :)
sibal gesekki
3,484 Pointssibal gesekki
3,484 Pointsthnx. i watched andrews solution but to me it was absolutely awful and confusing and i had to quit halfway. that ^ and my solution is better