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
liam johnshon
Courses Plus Student 904 Pointswhy length of quiz.questions is 0 ?
hey here is my code when i type quiz.questions.lenght in console the length of question display as 0 ..!
function Ques_obj(ques,choices,answer){
this.ques = ques;
this.choices = choice;
this.answer = answer;
}
function Quiz(){
this.questions = [];
this.currentQuestion = 0;
this.score = 0;
}
Quiz.prototype.add = function(ques){
this.questions.push(ques);
};
//creating instance of Quiz
var quiz = new Quiz();
//creating instance of Ques_obj
var ques_1 = new Ques_obj("What's my name ?",["Ashish","Rohan","Rohit","Pawan"],"Ashish");
var ques_2 = new Ques_obj("What's my age ?",["10","20","18","19"],"19");
var ques_3 = new Ques_obj("What's my profession ?",["Developer","Mechanic","Driver","Operator"],"Developer");
quiz.add(ques_1);
quiz.add(ques_2);
quiz.add(ques_3);
liam johnshon
Courses Plus Student 904 Pointsit doesn't work
1 Answer
Steven Parker
243,656 PointsI'm surprised you didn't get undefined.
function Ques_obj(ques, choices, answer) {
this.ques = ques;
this.choices = choice; // <-- you left off the final "s", try "choices"
this.answer = answer;
}
liam johnshon
Courses Plus Student 904 Pointsactually i m working on codepen so i didn't get error thanx steven
Kenneth Jones
6,656 PointsKenneth Jones
6,656 PointsI think you need to do quiz.questions.push(ques_1);