I started learning JavaScript about a week ago and now I have encountered a problem. My code is not returning proper random number as an answer. Please have a look at my code and help me out. Thanks.
function calc() {
var min = document.getElementById('min').value;
var max = document.getElementById('max').value;
var x = Math.floor(Math.random() * (max - min) + max);
document.getElementById('random').innerHTML = x;
}
<table border='1px' color='black'>
<tr>
<td>min</td>
<td>
<input type='text' id='min' />
</td>
</tr>
<tr>
<td>max</td>
<td>
<input type='text' id='max' />
</td>
</tr>
<tr>
<td>
<input type='button' onClick='calc()' value='generate' />
</td>
<td>
<p id='random'>0</p>
</td>
</tr>
</table>