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 trialJeffrey Benson
Courses Plus Student 3,304 PointsI was able to accomplish the goal and add a few extras too it. Love learning this JavaScript!
/* RANDOM NUMBERS BETWEEN TWO USER PROVIDED NUMBERS */
var firstNum;
var secondNum;
var randNum;
var step;
var quantity;
alert('Please enter three integers, a lower number, a higher number, and the quantity of random numbers to generate. The computer will generate that quantity of random numbers in between those two numbers.');
firstNum = parseFloat(prompt('Please enter the lower number:'));
secondNum = parseFloat(prompt('Please enter the higher number:'));
quantity = parseFloat(prompt('Please enter the quantity of numbers:'));
document.write('<H1>Random Numbers Within User Provided Parameters.</H1><p></p><H2>The lower number you entered is: ' + firstNum + '</H2><H2>The higher number you entered is: ' + secondNum +'</H2><p></p>');
function getRand(lo,hi) {
return Math.round( Math.random() * (hi-lo)) + lo + 1;
}
document.write('<P></P><H1>The ' + quantity + ' random numbers:</H1><p></p><H3>');
for (step = 0; step < quantity; step++) {
// Runs quantity times, with values of step 0 through quantity-1.
randNum = getRand(firstNum,secondNum);
document.write('<span>' + randNum + ' | </span>');
}
document.write('</H3><p></p>');
3 Answers
pi R
12,720 Pointsgood job :)
Jason Anders
Treehouse Moderator 145,860 PointsThank you Jeffrey for sharing your code with others... sharing is one of the best ways to learn new things and new ways.
Keep Coding! :)
Jeffrey Benson
Courses Plus Student 3,304 PointsWhat was the proper way for me to present the code? How did Chyno Deluxe fix the presentation for me?
Jason Anders
Treehouse Moderator 145,860 PointsHey Jeffrey,
If you go back into your question and click on the ... under your question, you will have an option to "edit question." Once you do that you will see where Chyno added a line-break and then 3 backticks with the programming language. At the end of the code it was closed with another 3 backticks. Doing this will format the code into a code block and the syntax highlighting will reflect the programming language stated.
If you meant "how was he able to", we as moderators can edit other students' questions.
Chyno Deluxe
16,936 PointsHow to post Code
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 Points//Fixed Code Presentation