Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript Working with Classes in JavaScript Adding methods to classes

"Inside the stringGPA() method, convert the value of the gpa property to a string and return it."

What am I doing wrong?

adding_methods.js
class Student {
    constructor(gpa){
        this.gpa = gpa;
    }

  stringGPA(){
    return this.gpa.toString;
  }

}

const student = new Student(3.9);

1 Answer

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Full Stack JavaScript Techdegree Graduate 25,264 Points

Hi Hazell!

You're so close! .toString() is a method so we need to add the parenthesis after it. All you have to do is add the () to the end of .toString and you're good to go.

Hope this helps!

Great, thanks so much for your help :)

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Full Stack JavaScript Techdegree Graduate 25,264 Points

Of course! If you're satisfied with my answer you can go ahead and click "best answer" to close out this discussion. It's just a way of letting others know that this question is resolved, this discussion will still be available!