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 JavaScript Basics Making Decisions in Your Code with Conditional Statements Add an 'else if' Clause

pinky
pinky
2,289 Points

Im not sure where im going wrong please can someone help me

so im not sure what im doing wrong in my code. some insight would be nice.

script.js
const isAdmin = false;
const isStudent = true;
let message;

if ( isAdmin ) {
  message = 'Welcome admin';
}
else if (isStudent)
  message = "Welcome student";
}

4 Answers

Phil Wright
Phil Wright
3,654 Points

Hi Pinky

You’ve got this, it is just missing an opening brace '{' after (isStudent) to balance everything.

const isAdmin = false;
const isStudent = true;
let message;

if (isAdmin ) {
  message = 'Welcome admin';
} else if (isStudent) {
  message = "Welcome student";
}
Adrian Ralston
Adrian Ralston
6,830 Points

It seems very solid but notice you overlooked one curly bracket in the second half of your code

else if (isStudent)
  message = "Welcome student";
}
pinky
pinky
2,289 Points

Thank you guys so much.

no problem !

Hey pinky! Looks like you almost had it ! I see a few people giving you the answer already but for the future just make sure you create {} marks first and just type within both of them. That way you have a much harder time forgetting them. Best of luck ! Here is the solution.

const isAdmin = false;
const isStudent = true;
let message;

if ( isAdmin ) {
  message = 'Welcome admin';
}
else if (isStudent) {
  message = "Welcome student";
}