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

Not sure what I’m missing on this code. Can anybody explain

script.js
const isAdmin = true;
const isStudent = false;
let message;
if (Welcome admin) { 

}

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 10,726 Points

Honestly I recommend you re-watch the video on if statements, your syntax is completely wrong unfortunately. Within your if statement your are supposed to have a condition or a statement that returns either a condition or Boolean. Examples

// Checking if a name is equal to Bob
let name = 'Jackson';
if(name === 'Bob') {
     console.log('Hi Bob');
}

// Checking if 10 is less than 20
if(10 < 20) {
    console.log('10 is less than 20')
}

See how the syntax differs from yours?

The challenge is probably asking you to check conditions for those variables, for example if isAdmin is true and then change the value of the message accordingly

if(isAdmin) {
   message = 'Welcome admin!';
}

Hopefully this helps.