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 an Else If Clause

Vishakha Agarwal
Vishakha Agarwal
9,130 Points

Problem with a challenge

Hi,

I am not able to find out the mistake in this code. Each time I run this code it gives me an error saying, "I don't see welcome student." However, same code did not give any error when I wrote it in console. I can not go further if I don't complete this challenge.

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

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

3 Answers

This challenge checks for an exact string to parse. This means it is a case-sensitive answer. Try changing "Welcome Student" to "Welcome student".

Saira Bottemuller
PLUS
Saira Bottemuller
Courses Plus Student 1,749 Points

The challenges are VERY picky this way. I would agree with @sean's answer; I was going to suggest removing the space between 'if' and '( is Admin )' ---- so, instead of " if ( is Admin ) " you'd have " if( isAdmin ) " --- but according to W3Schools, that shouldn't matter. Did you try @sean's suggestion, and did it work for you? I remember having some trouble with this particular challenge myself a few months ago.

Vishakha Agarwal
Vishakha Agarwal
9,130 Points

Thanks @Sena and @Saira, changing "Welcome Student" to "Welcome student" worked.