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 (Retired) Making Decisions with Conditional Statements A Basic If Statement

Stage 4: Making Decisions with Conditional Statements Challenge

Can someone tell me why my code isn't working?

var isAdmin = true; var isStudent = false if ( isAdmin === true ) { document.write('<p>Welcome administrator</p>'); } else { document.write('<p>You are not the administrator</p>'); }

When I check my answer it tells me that I am wrong and asks if I have added the word 'true' inside of the () of the if clause. I have but I still get it wrong. Thanks for the help.


3 Answers

Sam Baines
Sam Baines
4,315 Points

Hi Donte - the reason the code isnt working is because you are using the document.write command instead of the alert() command I believe - so as follows:

if (isAdmin === true) {
alert('Welcome Administrator');
} else {
alert('You are not the Administrator');

Hope this helps. Always read the challenge again if you get a bummer come back.

It's asking for an alert if isAdmin is true.

var isAdmin = true;
var isStudent = false;

if(isAdmin === true) {
  alert('Welcome administrator');

Thanks, somehow I kept overlooking that.