如何用javascript的for循环实现一个加法,

2024-11-29 06:07:40
推荐回答(1个)
回答1:





function sumnumber(){
var i = document.getElementById(num1) .value;
var j = document.getElementById(num2) .value;
if(i>j){
for(int k=j;k<=i;k++){
var sum = 0;
sum = sum+k;
}
}else{
for(int k=i;k<=j;k++){
var sum = 0;
sum = sum+k;
}
}
}