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 trialsuzan lohm
1,892 Pointswhy won't this part pass?
won't pass this code, what is wrong?
var answer=prompt('What is the best programming language?');
if (answer==='JavaScript') {
document.write ("<p>You are correct</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>
3 Answers
Marcus Parsons
15,719 PointsHey Suzan,
The challenge wants you to use an alert box instead of document.write. You don't need any elements for an alert box.
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert('You are correct');
}
Flavio Carvalho
26,636 PointsHi suzan,
Are you typing 'JavaScript' exactly that way? The string is case sensitive, if you type 'javascript' it won't work. Try including an 'else' document.write ("wrong answer"); type of thing to see if you get that back.
If so, then you'd need to test the string with a toLowerCase method, to make sure whatever way you type 'Javascript' it'll always be true.
See if that helps and let us know! :)
suzan lohm
1,892 PointsThank you
Marcus Parsons
15,719 PointsYou're welcome!