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

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 11,075 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.