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 trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Add a Final Else Clause

Cassandra Munson
Cassandra Munson
1,747 Points

final else

I cannot seem to complete the final "else" to this challenge. I have tried using the var(s) in the parentheses and with &&, || etc. what am I doing wrong?

```script.js
var isAdmin = false;
var isStudent = false;

if ( isAdmin ) {
    alert('Welcome administrator');
} else if (isStudent) {
    alert('Welcome student');
} else ( !== ) {
  alert('Who are you?');
}
index.html
<!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

Hi Cassandra,

In the final else statement, you don't need any parentheses. You are only asking for it to be if the other two conditions aren't resolved as true.

Your final code should look something like this:

var isAdmin = false;
var isStudent = false;

if ( isAdmin ) {
    alert('Welcome administrator');
} else if (isStudent) {
    alert('Welcome student');
} else {
    alert('Who are you?');
}

I hope this helps :)

Happy Coding!

Can you give Taylor Michel a "Best Answer" so that this question isn't in the "Unanswered Questions" section of the Community? Thank you for the convenience! ~Alex

Glad I could be of assistance! :)