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 Project Overview

Uncaught TypeError: questionlist.add is not a function

I am getting this error and im not really sure why

Uncaught TypeError: questionlist.add is not a function

this is my code.

var score=0;
var footer=document.getElementById('progress');
var questionDiv=document.getElementById('question');
var choiceButton1=document.getElementById('choice0');
var choiceButton2=document.getElementById('choice1');
var questionButton=document.getElementsByClassName('btn--default');


function Question(question, answer, wrongAnswer){
  this.question=question;
  this.answer=answer;
  this.wrongAnswer=wrongAnswer;
};

function Quiz(){
  this.questionList=[];
  this.questionIndex=0;

};

var questionlist= new Quiz();


var q1=new Question('What is the name of the first president ?', 'George Washington', 'Benjamin Franklin');

var q2=new Question('What is the ships name on Star Trek?', 'Enterprise', 'Applepise');


 questionlist.add(q1);
 questionlist.add(q2);

2 Answers

Per Karlsson
Per Karlsson
12,683 Points

From the looks of it there is no method called add in Quiz.

Thank you so much my brain wasn't working.