Uncaught SyntaxError: Unexpected token ,

Viewed 195

My code appears to be correct, but when I run it I get Uncaught SyntaxError: Unexpected token , This is my code below:

function Classes(subject, class, scheduled) {
  this.subject = subject;
  this.class = class;
  this.scheduled = scheduled;
  this.checkAvailablility = function() {
return this.class - this.scheduled;
}; 
}

var CourseHistory = new Classes('history', 30, 23);
var CourseScience = new Classes('science', 45, 38);
1 Answers

class is a reserved keyword in Javascript. You can't use it as a variable name.

When the function definition is parsed, the compiler expects a class name to be followed after class keyword, when it is not present it throws a syntax error as it does not conform to the syntax.

Related