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 trialarshia mohammadi
7,657 PointsI can't understand this challenge can someone help plz!
Inside the stringGPA() method, convert the value of the gpa property to a string and return it.
class Student {
constructor(gpa){
this.gpa = gpa;
}
stringGPA(this.gpa) {
}
}
const student = new Student(3.9);
4 Answers
Steven Parker
231,275 PointsMethod parameters should be simple names (no "dot" constructs). But you don't need a parameter for this method.
You will need a "return" in the method body, to pass back the string version of the stored gpa value. And the "toString()" method could be handy here.
arshia mohammadi
7,657 PointsIt would be great if you wrote this in code your answer isn't clear to me.
Steven Parker
231,275 PointsThe whole point of the challenge is to give you the experience of writing the code. Give it your best shot, and if you still have trouble passing the challenge, post the code you've added here and we can give you some more specific pointers for fixing it.
Marcelo Pereira
12,169 Pointsclass Student { constructor(gpa, stringGPA){ this.gpa = gpa; } stringGPA(gpa){ return this.gpa = 'stringGPA' }
}
const student = new Student(3.9);
Sean Gibson
38,363 Pointsclass Student { constructor(gpa){ this.gpa = gpa; } stringGPA(){ return this.gpa.toString()} }
const student = new Student(3.9);
Steven Parker
231,275 PointsSteven Parker
231,275 PointsPerhaps adding these hints as comments will make it more clear: