0

I am new to JavaScript and currently studying constructor of class concept on Codecademy.

And my question is, what is the difference to make property between with this keyword and with let when property name is not same as the one in parameter?

I am doing some exercise on Codecademy, and when I put properties in the constructor like this, it says incorrect( but syntax error does not happen)

class Surgeon {
  constructor(name, department) {
    this._name = name;
    this._department = department;
    let _remainingVacationDays = 20;
  }

*correct answer on Codecademy

class Surgeon {
  constructor(name, department) {
    this._name = name;
    this._department = department;
    this._remainingVacationDays = 20;
  }

Thanks!

Nagisa Ando
  • 181
  • 1
  • 8

0 Answers0