I use math.js to calculate gcd for a series of numbers wich are taken from input. Among the tested options I mention:
- parseInt() and parseFloat()
- IaNr=document.getElementById("nrs").value
- math.gcd(nrs.value);
- math.gcd($("#nrs").val())
- IaNr.toString()
but it doesn't work.
what am I missing, because it doesn't calculate the numbers from input. it works when I provide the numbers directly. ex: math.gcd(4, 8, 25,74)
<script src="http://cdnjs.cloudflare.com/ajax/libs/mathjs/1.2.0/math.min.js"></script>
$(function(){
IaNr=$("#nrs").val()
DoGcd=math.gcd(IaNr)
$("#show").html(DoGcd)
})
<input id="nrs" value="14,92,34,78">
<div id="show"></div>