Super() Syntax Error


#1

I have used the super() function before and it has worked perfectly, but now I’m suddenly getting a syntax error that makes no sense. I’m pretty sure I spelled everything right and I looked back into the lesson and the syntax seems right.

class Media{
  constuctor(title){
    this._title = title
    this._isCheckedOut = false
    this._ratings = []
  }
  get title(){
    return this._title
  }
  get isCheckedOut(){
    return this._isCheckedOut
  }
  get ratings(){
    return this._ratings
  }
  set isCheckedOut(newVal){
    this._isCheckedOut = newVal
  }
  toggleCheckOutStatus(){
    this._isCheckedOut === !this._isCheckedOut
  }
  getAverageRating(){
    let ratingSum = this.ratings.reduce((currentSum, rating) => currentSum + rating, 0)
    let lenOfRatings = ratings.length
    return ratingSum / lenOfRatings
  }
  addRating(newRating){
    this._ratings.push(newRating);
  }
}

class Book extends Media{
  constuctor(title, author, pages){
    super(title);
    this._author = author
    this._pages = pages
  }
   
  get author(){
    return this._author
  } 
  get pages(){
    return this._pages
  }
}

class Movie extends Media{
  constuctor(title, runTime){
    super(title);
    this._runTime = runTime
  }
  get runTime(){
    return this._runTime
  }
}  


#2

What is the syntax error saying?


#3
/home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:34
    this._title = super(title);
                  ^^^^^
SyntaxError: 'super' keyword unexpected here
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)

Weird right?


#4

That’s not really the error, though. Just what got flagged because it is unexpected. The real error is the misspelling above it.

The same spelling error occurs in all three classes.


#5

Omfg :joy::joy::joy: I cannot believe I missed that. Lets pretend this never happened :zipper_mouth_face: