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 trialJames Wood
9,804 Pointsconverting a number to a string inside of a method??
The question asks me to convert the gpa to a string inside of the stringGPA method...I'm not sure where I'm going wrong and I am well and truly stuck (fairly new to JS)
class Student {
constructor(gpa){
this.gpa = gpa
}
stringGPA(string) {
string = "'" + this.gpa + '"'
}
}
const student = new Student(3.9);
1 Answer
zentronic
7,593 PointsHi James,
Try the num.toString();
method for that. See the example below:
Hope i could help you & have a nice Day!
class Student {
constructor(gpa){
this.gpa = gpa;
}
stringGPA() {
return this.gpa.toString()
}
}
const student = new Student(3.9);