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 trialJosias Kabore
Full Stack JavaScript Techdegree Student 2,652 Pointscant figure out what's wrong with this code
else if code
var isAdmin = false;
var isStudent = true;
if ( isAdmin ) {
alert('Welcome administrator');
}else if(isStudent){ alert('welcome student');}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Joe Beltramo
Courses Plus Student 22,191 PointsThere is nothing wrong with the code you wrote, however I am pretty sure you are asking, why your challenge is failing. That would be because the alert you are outputting is not identical to what the challenge asked for. The expected result is case sensitive.
Just simply capitalize the W
in your welcome student
alert :]
Brandon Leichty
Full Stack JavaScript Techdegree Graduate 35,193 PointsHello Josias Kabore,
Is there something specific that's not working with your code? I ran your code in my browser and everything worked fine. I even switched the variables around to look like this:
var isAdmin = true;
var isStudent = fasle;
And everything still worked.