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

Alex Ng
Alex Ng
10,549 Points

Why has the class I'm trying to create already been declared for the code challenge? (Object Oriented JavaScript)

I was asked to create and empty class called "student".

When I submitted

class student {}

The error was was returned that it has already been declared. Why?

creating_class.js
class student {

}
Alex Ng
Alex Ng
10,549 Points

The following code won't work either, I get the same error...

class student {
     constructor () {}
};

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,526 Points

Hi Alexander Ng

You are naming the class student (note the lower-cased 's'). Classes should always be Title-cased. If you have a look at the instructions, it does say to name it Student (note the upper-cased 'S'). Remember, "student" and "Student" are two very different things.

The reason you got the error that you did is that the code checker probably has a variable named student it uses to test the code for the challenge.

Hope that helps. :) :dizzy:

Alex Ng
Alex Ng
10,549 Points

sigh I try not to ask for help on the little mistakes but, well... here we are...

Fate would have it that as soon as I asked the question, I figured it out.

Thanks, Jason.

Jason Anders
Jason Anders
Treehouse Moderator 145,526 Points

No worries. :)

We have all done it... and we will almost certainly all do it again. Never worry about "little mistakes"... the Community is always welcoming and willing to help. You'd be surprised how many experience that same 'blind' moment. Fortunately, there are also many, many 'ah-ha!!' moments too.

You're doing great! :smiley: :thumbsup: