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

Melissa Preece
Melissa Preece
Full Stack JavaScript Techdegree Student 7,456 Points

Help! code challenge in Object-Oriented JavaScript course

Hi all, I am stuck on task 2 of this challenge. Not quite sure how to convert a numeric value into a string. I looked online and possibly found a solution using ' ' + gpa, but that doesn't seem to work. Can someone help please? Here's the link: https://teamtreehouse.com/library/objectoriented-javascript-2/working-with-classes-in-javascript/adding-methods-to-classes

adding_methods.js
class Student {
    constructor(gpa){
        this.gpa = gpa;
    }
    stringGPA(gpa) {
        this.gpa = '' + gpa;
        return gpa;
    }
}

const student = new Student(3.9);

1 Answer