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 trialRyan Lee
13,806 PointsSyntaxError: 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?
var isAdmin = false;
var isStudent = false;
if ( isAdmin = true ) {
alert('Welcome administrator')
} else if ( isStudent = true ) {
alert('Welcome student')
} else {
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>
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHi 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
13,806 PointsRyan Lee
13,806 Pointsyikes, how embarrassing. I spent a good 15-20 minutes looking at this too -_-. Thanks for the help!
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsHey 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. :)