-1
每当我按下我的程序中的按钮,它说最大的调用大小已超出,我不知道如何做我的程序运行。程序最大调用堆栈超过
这是代码。
function check() {
var input = document.getElementById("num").value;
var check = /^[0-9]*$/;
check.test(input) ? window.alert("You have only entered numeric characters! Please proceed to press one of the other buttons.") : window.alert("Please enter only numbers!");
}
function abs() {
var abs_input = document.getElementById("num").value;
document.write("The absolute value of your number is: " + abs(abs_input));
}
function round() {
var input = document.getElementById("num").value;
document.write("The value of your number rounded is: " + round(input));
}
function log() {
var input = document.getElementById("num").value;
document.write("The natural logarithm of your number is: " + log(input));
}
<center>
<label style="font-size:40px">Please Enter A Number Here:</label>
<input type="text" id="num" style="font-size:40px">
<br />
<br />
<br />
<br />
<button type="button" onclick="check()" style="font-size:20px">Check</button>
<br />
<br />
<br />
<br />
<button type="button" onclick="abs()" style="font-size:20px">Absolute Value</button>
<br />
<br />
<br />
<br />
<button type="button" onclick="round()" style="font-size:20px">Rounded Value</button>
<br />
<br />
<br />
<br />
<button type="button" onclick="log()" style="font-size:20px">Log Value</button>
<br />
<br />
</center>
它因为无穷的递归。你能解释你想达到的目标吗? – Rajesh