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.

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

Julien Arseneau
Julien Arseneau
Full Stack JavaScript Techdegree Student 5,200 Points

Can someone explain me how to convert a value in a string?

I can't do it inside this method inside the class

class Student {
        this.gpa = gpa;


const student = new Student(3.9);

3 Answers

There is special syntax you can use for this. Don't know if you've seen it before, but you can make a string with backticks, then using `${// Write code here}` inside the backtick string, you can input regular JS values in the curly braces and it will convert that value to a string. For you, it would look like this:

stringGPA() {
  return `${this.gpa}`;
Corey Montgomery
Corey Montgomery
18,054 Points

For this you need to apply the .toString() method to the gpa variable and return it through the stringGPA method. Hope that gives you enough of a hint to complete the challenge. If not, let me know.