random number js min max
<p>I'm trying to get random number between 2 numbers from input in JavaScript. When I put numbers instead of max.value and min.value it works, but not with variable. I can't understand how does random in js work, in other programming languages I know it's easy done like random(min,max) so I totally don't understand why is it so hard in JS. Thank you.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function genRanNumb() {
  document.getElementById('demo').innerHTML=Math.floor(Math.random()*(max.value-min.value+1)+min.value);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" id="min"&gt;
&lt;input type="text" id="max"&gt;
&lt;button id="btn" onclick="genRanNumb()"&gt;button&lt;/button&gt;
&lt;p id="demo"&gt;&lt;/p&gt;</code></pre>
</div>
</div>
</p>