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 A Basic If Statement

slava vissoki
PLUS
slava vissoki
Courses Plus Student 1,709 Points

help with task

hi i need to complete this task , this what i write and it doesnt work please help:)

var isAdmin = true; var isStudent = false; if (isAdmin===true) { alert = ('Welcome administrator'); }

script.js
var isAdmin = true;
var isStudent = false;
if (isAdmin===true) {
  alert = ('Welcome administrator');
}
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

Steven Parker
Steven Parker
231,236 Points

You're very close — except for a little typo.

:point_right: You have a stray equal sign (=) between the alert function and its parentheses.

Also, while it doesn't hurt anything, you never need to compare a boolean against true. You can test the boolean directly, like this:

if (isAdmin)
Yazeed Bzadough
Yazeed Bzadough
4,880 Points

Hi Slava,

As Steven said, you have a stray = in your if statement. That's actually assigning the alert function to ('Welcome administrator'); If you wish to invoke the alert function, use parenthesis with the argument you wish to pass in.

if (isAdmin === true) {
  alert('Welcome administrator');
}