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 trialGena Israel
2,047 Pointsnot sure im doing this correctly
i took 2 weeks off javascript and am refreshing
var isAdmin = true;
var isStudent = false;
if (isAdmin= true) {prompt("Welcome Administrator")};
<!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
Umesh Ravji
42,386 PointsHi Gena, there are two small issues with the code.
if (isAdmin = true) { // [1]
prompt("Welcome Administrator") // [2]
};
Two weeks is a while, here's what you may have forgotten.
Comparisons to see if two 'things' are equal are done using double equals (==). Assignment is done using a single equals (=), so you aren't actually comparing the value of isAdmin to true, you are assigning it the value of true.
Prompts are used to gather inputs from the user. You want to use an alert here to display the message because you are simply telling them something.
You don't need the semicolon at the end of an if statement.
if (isAdmin == true) {
alert("Welcome Administrator");
}
Gena Israel
2,047 PointsGena Israel
2,047 Pointserror i got was the following: Did you add
true
inside the parentheses of the conditional statement?