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! While you're at it, check out some resources Treehouse students have shared here.
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 trialAdrian Bernard
9,165 PointsstringGPA
I Need a little Assistance with this one.
class Student {
constructor(gpa, stringGPA){
this.gpa = gpa;
this.stringGPA = stringGPA;
}
stringGPA (){
return toString(this.gpa);
}
}
const student = new Student(3.9);
2 Answers
Steven Parker
231,269 PointsYou're close, but "toString" is not a function. It's a method you would call using dot notation:
return this.gpa.toString();
Adrian Bernard
9,165 PointsThank you very much, got it! Was a little bit off but its sorted now thank you.
Jamie Carter
Front End Web Development Techdegree Student 12,096 PointsJamie Carter
Front End Web Development Techdegree Student 12,096 PointsAnd following on from Steven, that expression is Object Oriented Javascript.
Object.toString() is just what you are building for Student.stringGPA()
Lots of base things like arrays and objects have these kinds of properties. It blew my mind when I realised this.
another example is Array.length