Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Haardik Gupta
Full Stack JavaScript Techdegree Student 5,459 Pointsconvert to string classes
in this exercise im being asked to convert the value of the gpa property to a string inside of the stringGPA method
but i cant seem to understand what that means
class Student {
constructor(gpa, stringGPA){
this.gpa = gpa;
this.stringGPA = stringGPA;
}
stringGPA() {
console.log(this.gpa);
}
}
const student = new Student(3.9);
4 Answers

Steven Parker
216,863 PointsDimitar is partially correct, but when they say "convert the value" they mean just to create the return value, not to change what is being stored:
return this.gpa.toString();
You should also not modify the provided constructor code. Just add the new method.

Dimitar Dimitrov
11,800 PointsIn the stringGPA method you just need to use the JavaScript method toString()
on this.gpa
and assign its new value like this:
return this.gpa = this.gpa.toString();
toString() method converts your data to a string that is all you need to do

Haardik Gupta
Full Stack JavaScript Techdegree Student 5,459 Pointsim getting an error saying
Bummer: student.stringGPA is not a function
with this
class Student { constructor(gpa, stringGPA){ this.gpa = gpa; this.stringGPA = stringGPA; } stringGPA() { return this.gpa.toString(); } }
const student = new Student(3.9);

Steven Parker
216,863 PointsFor this challenge, you are asked only to add a new method. The instructions don't say anything about modifying the constructor code that was provided.

Haardik Gupta
Full Stack JavaScript Techdegree Student 5,459 Pointsthank you for the help