Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Ryan Lee
Ryan Lee
13,806 Points

SyntaxError: Parse error on Challenge Task 1 of 1 "Add a final else clause"

Tried looking on the forums for this, as far as I can tell my code is correct but I am getting a syntax error "Parse error". Here's the code:

var isAdmin = false; var isStudent = false;

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

Can anyone help me with this one?

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

if ( isAdmin = true ) {
    alert('Welcome administrator')
} else if ( isStudent = true ) {
    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>

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,680 Points

Hi Ryan. You've got everything right, you are just missing your closing curly brace after the final alert to close the last else statement. Keep Coding! :)

Ryan Lee
Ryan Lee
13,806 Points

yikes, how embarrassing. I spent a good 15-20 minutes looking at this too -_-. Thanks for the help!

Jason Anders
Jason Anders
Treehouse Moderator 145,680 Points

Hey Ryan. No worries and nothing embarrassing. Even the most experienced coders make the simplest mistakes that usually a fresh set of eyes can catch easily. :)

Also, on a side note, in the forum, it is a good practice to mark "Best Answer" if your question/problem was solved, as this lets others in the forum know your question/problem is resolved.

Enjoy your Treehouse Experience. :)