Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsKeep getting syntax error
Don't understand what is wrong with my if statement.
var answer = prompt ("what is the best programing language?");
if (answer.toUpperCase() ==== RUBY){
document.write( "<p>That's right!<p>");
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
4 Answers

Christopher Debove
Courses Plus Student 18,372 PointsIn your example RUBY should be a string so you need to surround it with quotes on the comparison.
An there's no "====" operator in JavaScript :
// "==" : Simple comparison operator, ex:
1 == "1" // => true
// "===" : Strict comparison operator (check for type too), ex:
1 === "1" // => false

Christopher Debove
Courses Plus Student 18,372 PointsHumm that's surely because you need to open dialog than writing in document. So do not use "document.write", but the "window.alert" function which open a dialog

Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsHaven't learned that yet and wasn't used in the example but I'll try it.

Christopher Debove
Courses Plus Student 18,372 PointsThat's the first thing you learn : alert("Hello world")

Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsAlert and window.alert are the same? Thought that would make a difference.

Christopher Debove
Courses Plus Student 18,372 PointsLike it's said in the course, all global variable and function are part of window.
Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsKevin Lewis
Front End Web Development Techdegree Student 9,667 Pointsvar answer = prompt ("what is the best programing language?"); if (answer.toUpperCase() === "JAVASCRIPT"){ document.write( "<p>That's right!<p>"); }
This is how I fixed it by now it's asking if I used windows alert and I don't know what it means.