JS: Random number picker [help] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JS: Random number picker [help]

I’m trying to make a random number picker app with range (input1 - input2). Why do I just get 0? Or, umm... how do I make it work? I’ve tried everything I can, I give up. —— https://code.sololearn.com/WyvJUoo30cRT/?ref=app

3rd Jan 2020, 7:28 AM
Ginfio
Ginfio - avatar
4 Answers
+ 1
parseInt the input because they are string
3rd Jan 2020, 8:13 AM
Gordon
Gordon - avatar
+ 1
yes very close now now move commented line 9 line 10 to beginning of chooseNum() explain why 2 to 4 gives 02 and 12 the result is not outside range. is because minValue is string, computed floor result 0 or 1 concantention with the string 2.
3rd Jan 2020, 9:37 AM
Gordon
Gordon - avatar
0
the outside close bracket before + sign floor, then add min
3rd Jan 2020, 7:52 AM
Gordon
Gordon - avatar
0
Gordon , yeah, that leads to a different problem. It makes other random numbers without the range. __
3rd Jan 2020, 7:57 AM
Ginfio
Ginfio - avatar