有人可以解释如何在没有循环的情况下完成这项工作吗?
let x = prompt("Enter a first number to add:");
let y = prompt("Enter a second number to add:");
parseFloat(x);
parseFloat(y);
alert(peanoAddition(x, y));
function peanoAddition(x, y) {
while (y !== 0) {
if (y === 0) {
return x;
} else {
x = x + 1;
y = y - 1;
return x;
}
}
}