Welcome to the Treehouse Community
Looking to learn something new?
Aman Rai3,040 Points
I got the same result but with a different approach. Is my code still correct?
var selectNum = prompt('Insert a number'); var selectedNum = parseInt(selectNum); var selectNum2 = prompt('Insert another number'); var selectedNum2 = parseInt(selectNum2); var yourRanNum = Math.floor(Math.random() * selectedNum2) + selectedNum; var message = '<p>' + yourRanNum + ' is a number between ' + selectedNum + ' and ' + selectedNum2 + '</p>'; document.write(message);
HIDAYATULLAH ARGHANDABI21,030 Points
Dear Aman Rai, I checked your code you are doing great job. One question can have many approaches to solve if your answer is satisfied by the terms required then it is perfect. In software engineering we have a term called KISS- It means keep it simple. If it works it is your best method.
Chevy McMartin9,680 Points
Hi, your code won't work properly. Try your code using some high numbers like from 100 to 110.
It's just the math logic.
Willemijn B5,577 Points
I did the same thing and I can't seem to figure out the math that makes high numbers not work properly with this approach (whereas it does work with the solution given). Can someone explain?