flatbubba
11/26/2017 - 10:54 PM

Constructors

//Create a new constructor
function Course(title,instructor,level,published,views){
 this.title = title;
 this.instructor = instructor;
 this.level = level;
 this.published = published;
 this.views = views;
 this.updateViews = function(){
   return ++this.views;
 };
}
 
//populate an array with new course objects
var courses = [
  new Course("Javascript Essential Training", "Joe Smith", 1, true, 0), new Course("Advanced Javascript", "Joe Martin", 2, true, 234234)   
];

//or create each new course individually
var course01 = new Course("Javascript Essential Training", "Joe Smith", 1, true, 0);
var course02 = new Course("Advanced Javascript", "Joe Martin", 2, true, 234234);