如何将函数 numOne 中的“x”调用到函数 numTwo 中?有没有更简单的方法来做到这一点?或者如何将 numOne 的结果调用到 numTwo 中?
<!doctype HTML>
<html>
<head>
<title>Function Testing</title>
</head>
<body>
<script type="text/javascript">
function numOne(x, y){
var x = 3;
var y = 4;
var result = x+y;
numTwo();
}
function numTwo(){
alert(x);
}
</script>
</body>
</html>
最佳答案
将结果传递给numTwo
:
function numOne(x, y){
var result = x+y;
numTwo(result);
}
function numTwo(r){
alert(r);
}
numOne(2, 3);
关于javascript - 如何将另一个函数中的数字调用到函数中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26437417/