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 trialROHITH CHITHRANGADHAN
9,006 Pointswhy i am being asked to add Else if clause even after adding else if to the conditional statement?
The task was to add an else if condition and i did it as well but still i'm get an error and it i being asked to add else if clause. What does this mean is the statement different from clause?
var isAdmin = false;
var isStudent = true;
if ( isAdmin ) {
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
Steven Parker
231,236 PointsYour code is correct and will pass the challenge. The "clause" is simply the combination of the conditional and statement.
Justin also makes a good point, it is not necessary to compare a boolean with "true", just naming it is enough (as was done with "isAdmin" in the provided code).
ROHITH CHITHRANGADHAN
9,006 PointsThanks Steven and Justin. I tried it out again and passed with same code. I don't understand what went wrong before. And you are right Justin comparison operator weren't necessary.
Justin Riley
3,175 PointsJustin Riley
3,175 PointsYou don't need the comparison operator in the conditional. the conditional itself is checking for it to be true inherently.