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 (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.