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

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";
}

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

else if (isStudent)
  message = "Welcome student";
}

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";
}