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

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
11,071 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;
}