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 Write an 'if' Statement

challenge task 1 of 1 conditional statements

can any one please give me a hint

script.js
const isAdmin = true;
const isStudent = false;
If (is admin){
let message= "Welcome admin";
}
Marcin Lipski
Marcin Lipski
9,947 Points

Hello Malcolm "if" should be non capitalized and "isAdmin" in brackets should be a one word with capital "A".

I hope this helps

2 Answers

Daniel Jong
Daniel Jong
10,538 Points

Hi, replay the video to see how Guil did it. 'if' is a syntax, you can't just change the i to uppercase and spread the camel cased isAdmin to is admin.

Here's my solution for this challenge:

const isAdmin = true;
const isStudent = false;
let message;
if (isAdmin){
    message= "Welcome admin";
}

Hope it helps!

I know this is an older post but I was hoping this may help someone out. Actually took me a bit to figure this answer out. I had the correct "if" statement but they also want you to add the "else" statement.

const isAdmin = true;
const isStudent = false;
let message;
if (isAdmin) {
message = "Welcome admin";
}else {
isAdmin = isStudent;
}