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 trial

JavaScript Object-Oriented JavaScript Working with Classes in JavaScript Creating a new class

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 {

}

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,857 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:

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,857 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: