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 Laszlo Vincze
4,083 PointsMy solution is good?
Hello,
Here is my solution. Is it good?
/* First Generator */
var ask = prompt("Tell a number please:");
var number = parseInt(ask);
var result = Math.floor(Math.random()*number)+1;
document.write("The" + " " + "number" + " " + "is" + " " + result + "<br /><br />" );
/* Second Generator */
var num = prompt("Tell a number please:");
var int = parseInt(num);
var num2 = prompt("Tell an other number please:");
var int2 = parseInt(num2);
var result2 =Math.floor(Math.random() * (int2-int))+int;
document.write("The" + " " + "number" + " " + "is" + " " + result2);
2 Answers
Robert Richey
Courses Plus Student 16,352 PointsHi Adam,
Working solutions are always good solutions. Nice job figuring out how to generate a random number from two user inputs!
One thing I noticed that might help to make it easier on you is to modify the document.write lines without concatenating spaces unnecessarily. Spaces can be part of a continuous string.
document.write("The number is " + result + "<br /><br />" );
Thanks for sharing!
Cheers
Adam Laszlo Vincze
4,083 PointsHi Robert,
thanks for help.
Cheers :)