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 trialAdam Kmet
1,039 Pointsim stuck with storing variable
can anyone see my mistake please?
var answer= prompt("What day is it")
alert(answer);
<!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>
5 Answers
andren
28,558 PointsYou are missing a question mark at the end of your string, it should be:
var answer = prompt("What day is it?")
The challenges are very picky about strings, they usually have to match the examples provided to the letter.
Pieter Bracke
4,078 Pointsyes ad ; to the end of your var line and it will work :)
so it should be : var answer= prompt("What day is it"); alert(answer);
Adam Kmet
1,039 Pointshi i just fixed it and believe or not the ; wasnt needed there the problem was that i was supposed to say what is your day? and I forgot to put the ? there hahahah...thank you for the quick answer
Adam Kmet
1,039 Pointsyes youre right it is indeed a good practice to have ; there
john larson
16,594 PointsI am going to agree with Andren. We are strongly encouraged to include ; at the end of lines. Most of the time it's not necessary. (but you will be shamed for not doing it) Oddly, not having a string EXACTLY the way the challenge presents it, will often cause a fail. Someone way smarter than me explained that js automatically puts ; in for you. (although it's not a guarantee) Not putting colons and commas in the correct places in lists will definitely break the code however.
Pieter Bracke
4,078 PointsPieter Bracke
4,078 PointsThat could also be the case. But see my answer 2 it is good practice to add ; after every line of code.
andren
28,558 Pointsandren
28,558 PointsIt's good practice, sure, but not mandatory unless you are writing multiple statements on one line. It's not something that would cause the challenge to fail the code.