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

Alert Dialog Box

When testing my answer I get " I don't see "Welcome Student" in the alert box. Although Alert box pops up with Welcome Student in it.

Not sure what I am doing wrong.

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

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

2 Answers

Samuel Durkin
Samuel Durkin
48,402 Points

Try uncapitalising "Student".

The challenge ask you to alert the string "Welcome student", it is very peculiar as to what it wants.

huckleberry
huckleberry
14,636 Points

This works just fine for me and I'm a bit confused about your question

When testing my answer I get " I don't see "Welcome Student" in the alert box. Although Alert box pops up with Welcome Student in it.

You say that you don't see Welcome student but rather you get an empty string in the alert box. But in the very next sentence you say that you DO get the alert box that pops up and it does indeed say Welcome Student.

soooo ... which is it? lol

Cheers,

Huck - :sunglasses:

edit: Have the syntax for blockquotes changed as of late?

Samuel Durkin
Samuel Durkin
48,402 Points

He sees the test fail, but he sees what he believes is the correct string in the alert box.

The sentence is a bit messy, but I think it's quite clear that's what he means.