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 trialdavid Ramirez
Courses Plus Student 2,798 Pointshelp please
i don't understand is it a if statement then a else if statement ?
var isAdmin = true;
var isStudent = false;
if(true){
document.write('true')
}
<!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
231,269 PointsHere's some hints:
- testing the value true is not a conditional statement (it's a certainty!)
- when testing a condition, you must name the value being tested in the if statement
- for this challenge, you won't need an "else"
- the challenge wants you to use alert, not document.write
- it also wants you to use a specific message. You can cut-and-paste that message to avoid typo's
Chyno Deluxe
16,936 PointsThe challenge asks that you create a conditional statement that test to see if the isAdmin variable is true. Then, If it is then open an alert with the message "Welcome administrator".
var isAdmin = true;
var isStudent = false;
if(isAdmin){
alert("Welcome administrator")
}
david Ramirez
Courses Plus Student 2,798 Pointsdavid Ramirez
Courses Plus Student 2,798 Pointsso it's a else statement?
david Ramirez
Courses Plus Student 2,798 Pointsdavid Ramirez
Courses Plus Student 2,798 Pointsso only a if statement?
Steven Parker
231,269 PointsSteven Parker
231,269 PointsYes, it will be just an if (and an alert).
I was betting you'd get it without an explicit spoiler, but I see someone's given one already anyway.