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 trialMichael Cornford
2,001 PointsIs there a bug? My code seems well structured and returns the correct results but the screen uses a red alert.
if(answer === "Javascript"){ alert("You are correct");
}
var answer = prompt("What is the best programming language?");
if(answer === "Javascript"){
alert("You are correct");
}
<!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>
3 Answers
Ron McCranie
7,837 PointsSee if you can spot the difference between what I have here and what you have.
var answer = prompt("What is the best programming language?");
if(answer === "JavaScript") {
alert("You are correct");
}
Michael Cornford
2,001 PointsYes I see the big S in JavaScript but it seems a bit pedantic to check the case of the s in Javascript when the test was about Javascript not typography. The alert fired because I was consistent in using the lower case s. The help code told me to check the === operator.
Ron McCranie
7,837 PointsI understand what you're saying but when writing code the case of letters can matter. If you set a variable as javaScript
and then try to refer to it as JavaScript
it would say that it's undefined. I too am not great with spelling but when you're in code writing mode, it really can make a difference.
Michael Cornford
2,001 PointsSorry thanks for the prompt reply, I have moved on. Spelling is not my strong subject.
Michael Cornford
2,001 PointsI started by using toUpperCase but the example fell over. I agree totally but I was testing against what I input. I find it really difficult to parrot and learn. I like to extend and break to learn. Sorry it is just a different style. Yes I have the four S's Syntax Spelling and Simple Steps. I know I spend too much time looking for errors in code and not checking the spelling.
In this example the debugger does not work the actual JavaScript ran as intended.