為什么按題要求顯示結(jié)果為NaN
??function??app2(x,y)
??{?var?sum,x,y;
????sum?=?x?*?y;
return?sum;
??}
var?req1=app2(5*6);
var?req2=app2(2*3);
var?sumq=req1+req2;?
document.write("req1的值:"+req1+"<br/>");
document.write("req2的值:"+req2+"<br/>");
document.write(req1+"與"+req2+"和:"+sumq);
</script>
2016-06-06
函數(shù)里面已經(jīng)有計(jì)算公式了,所以賦值的時(shí)候是不能有計(jì)算公式的;
正確代碼如下:
<script type="text/javascript">
? function ?app2(x,y)
? { var sum,x,y;
? ? sum = x * y;
return sum;
? }
req1=app2(5,6);
req2=app2(2,3);
sumq=req1+req2;?
?
document.write("req1的值:"+req1+"<br/>");
document.write("req2的值:"+req2+"<br/>");
document.write(req1+"與"+req2+"和:"+sumq);
</script>
2016-05-17
var?req1=app2(5*6);
var?req2=app2(2*3);
這兩個(gè)改為;
var?req1=app2(5,6);
var?req2=app2(2,3);
2016-05-15
括號(hào)里面數(shù)字應(yīng)該是逗號(hào)不是乘號(hào)
2016-05-13
去掉var