JavaScript Introducing ES2015 Classes Getter and Setter Methods

shirshah sahel
shirshah sahel
10,034 Points

Can some please take a look at what I might be missing in my code.

'use strict';

class Student {

  get name(){
  return `${this.firstName} ${this.lastName}`;
  }


  constructor({ firstName, lastName, age, interestLevel = 5 } = {}) {
    this.firstName= firstName;
    this.lastName= lastName;
    this.age = age;
    this.interestLevel = interestLevel;
  }
}

let stevenJ= new Student({firstName: 'steven';, lastName:'Jones', age: 22});
console.log(stevenJ.name);    

3 Answers

Steven Parker
Steven Parker
171,120 Points

On the 2nd to last line, there's a stray extra semicolon between the name 'steven' and the comma.

Nafis Fuad
Nafis Fuad
35,503 Points

ah... Eagle eyes.

Steven Parker has the Eyes of an Eagle

shirshah sahel
shirshah sahel
10,034 Points

Thank you Steven, got it.