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 trial
Samarth Jajoo
3,572 PointsWhat's wrong with this JavaScript?
Here's my code ->
<script> var input1 = prompt("Enter the maximum number."); var input2 = prompt("Enter the minimum number."); var random = Math.floor(Math.random() * (max - min) + 1) + min; alert(random); var max = parseInt(input1); var min = parseInt(input2); var message = "<p>" + random + "is a number between" max "and" min "</p>"; document.write(message); </script>
The only error I get is that there is a unknown and unexpected identifier on line 8.
2 Answers
fbriygig
15,370 PointsHi, I think the formatting is a bit off when you declare the string to the message variable. Does this work better?
var message = random + " is a number between " + min + " and " + max;
sometimes the editor tries to help you by giving you double sets of quotation marks when you only press the button once. It can cause problems sometimes.
fbriygig
15,370 PointsGlad to help :)
Samarth Jajoo
3,572 PointsSamarth Jajoo
3,572 PointsThanks a lot :D