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 trialEmil Ty
5,844 PointsNot sure what I'm doing wrong.
error says 'Welcome student' is not in message, but it is? I'm sure I'm missing something small...but I can't find it...
var isAdmin = false;
var isStudent = true;
if ( isAdmin = true ) {
alert('Welcome administrator');
} else if (isStudent = true) {
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>
2 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsAlways leave the original code as-is unless specified. all you need to do is test isSdudent
, not isStudent == true
. Doing it that way will automatically check for the value true:
var isAdmin = false;
var isStudent = true;
if ( isAdmin ) {
alert('Welcome administrator');
} else if (isStudent) {
alert('Welcome student');
}
Benjamin Hess
1,635 PointsI'm stuck on the next part after this. I don't know what to put. else(){ } Am I suppose to put something in the ()?
simon lavery
17,485 PointsYes you add whatever condition needs to be true to run the code inside the {}. So you have if (isAdmin) {do this}
else (????) do this
On this challenge there only is one other option so you could leave it blank, i think it should work either way.
simon lavery
17,485 Pointssimon lavery
17,485 Pointsthis works :)