I have this as my generate random number function:
function getRandomNumber(min, max) {
var x = document.getElementById("ok");
for(var i = 0; i < 10; i++) {
var c = Math.floor(Math.random() * (max - min + 1)) + min;
x.innerHTML += " " + c;
}
}
If i use getRandomNumber(5, 10);, the code works as intended and generates numbers through 5-10, but if i use the document.getElementById(‘num1’).value and the other one, the code doesn’t work.
I did console.log tests and it does print the correct value of the inputs… I don’t know why.
Just a fyi, The ‘//’ in the code are only there so i can post it, otherwise it wouldnt show for some reason. There are no syntax errors in the console.log report
Also, I think you have to either change the input types to number or use parseInt() to make sure that all values in your function are numbers and not strings.
Oh, i understand now. thats why my min value was always at the end of the number because it thought i was concatenating a string instead of doing a math formula.