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 Creating a new class

Alonzo Delk
Alonzo Delk
6,991 Points

Adding Properties

Can I get some on this objective. I'm supposed to be adding a parameter?

creating_class.js
class Student {
  constructor(gpa, property) {
   this.parameter = gpa;
   this.property = parameter;
  }
}

2 Answers

Jamie Moore
Jamie Moore
3,943 Points

Hey Alonzo,

I think you're nearly there, but you're adding a few things that don't need to be there. You currently have two parameters, gpa and property but there should only be gpa. You then need to declare an attribute gpa, which is equal to the parameter being passed in, like so:

class Student {
  constructor(gpa) {
     this.gpa = gpa;
  }
}
Alonzo Delk
Alonzo Delk
6,991 Points

Thanks Jamie and my biggest problem with coding is the javascript area, but for you to understand it is great. I'll keep praciting and working towards this challenge.