I have this javascript code, and it is supposed to solve for x and y, but the result it gives is NaN.
function calculate(x,y){
var firsttrans="1";
var secondtrans="2";
var a=parseInt(firsttrans, 10);
var b=parseInt(secondtrans, 10);
var y=x*a/b;
var ans=parseInt(y, 10);
alert(ans);
}
I need firsttrans
and secondtrans
to be strings because of something else in my code, but the point is that this alert(ans)
doesn't give a number.