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 trialDaniella Bagon
3,796 PointsJavaScript Basics - Boolean Value Challange
Hi I can't seem to pass this challenge, can someone tell me where I am going wrong please?
Thanks.
var isAdmin = false;
var isStudent = false;
if ( isAdmin === true ) {
alert('Welcome administrator')
} else if (isStudent === true) {
alert('Welcome student')
}
else ( false ) {
alert('Who are you?');
}
<!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
Dan Oswalt
23,438 PointsHi, you don't need the (false) expression in the else statement. That test wouldn't make much sense, as it is testing if 'false' is 'true'. You don't need any expression there at all to catch when both isAdmin and isStudent are false.
var isAdmin = false;
var isStudent = false;
if ( isAdmin === true ) {
alert('Welcome administrator')
} else if (isStudent === true) {
alert('Welcome student')
} else {
alert('Who are you?');
}
Jason Anders
Treehouse Moderator 145,860 PointsHi Daniella,
You are close, but for the final 'else' statement, you don't need to pass in a value (you passed in 'false'). If the 'if' conditional fails, it moves on to the 'else if.' If that one fails, it will run the 'else' block regardless.
So, all you need is
else {
alert('Who are you?')
}
Hope that helps. Keep Coding! :)