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 trialGulchin Gulmamadova
Courses Plus Student 1,362 Pointsi am back with basic JavaScript question
here it is.
var answer = prompt("What day is it?");
document.write"(Monday");
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
8 Answers
Joseph Zimmerman
6,402 Pointsare you trying to alert the answer from the prompt?
alert(answer);
Gulchin Gulmamadova
Courses Plus Student 1,362 Pointsthanks! i see that
Gulchin Gulmamadova
Courses Plus Student 1,362 Pointsit says the first code doesn't work now. why?
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script src="javascript.js"></script> <script> alert("Warning!"); </script>
</body> </html>
Joseph Zimmerman
6,402 PointsThat's where you lose me that challenge does not require an alert.
Gulchin Gulmamadova
Courses Plus Student 1,362 Points<script src="javascript.js"></script> <script> alert("Warning!"); </script> where is the problem that makes the first code stop working?
Gulchin Gulmamadova
Courses Plus Student 1,362 Pointsi know, it is so simple, isn't it? but it is not going through for some reason.
Joseph Zimmerman
6,402 PointsPlease provide complete code examples. Your code above does not have an alert.
Todd MacIntyre
12,248 Pointsalert(answer);
Try this
Gulchin Gulmamadova
Courses Plus Student 1,362 PointsTodd, I am going trough beginning lessons in JavaScript and the problem tells you specifically to use document.write().
Todd MacIntyre
12,248 PointsPaste the challenge instructions and the code you are trying to use here please so I can take a look.
Gulchin Gulmamadova
Courses Plus Student 1,362 PointsGot it! Thanks guys!
Joseph Zimmerman
6,402 PointsJoseph Zimmerman
6,402 PointsWhat's happening is your prompting the user and the storing it in the variable answer. You then write the prompted variable to the page. Also, you need to move your quote on the variable inside the parenthesis.
change the last line to: document.write("answer");