为什么for循环不能反向工作

Why for loop does not work in reverse

本文关键字:工作 不能 for 循环 为什么      更新时间:2023-09-26

为什么这个反向for循环不起作用?

var a  =1;
for(i=100; i<0; i--){
    a = a+i;
}
console.log(a);

for(i=100; i>0; i--){
    a = a+i;
}

您的情况不正确

您的情况不正确

  for(i=100; i>0; i--){
        a = a+i;
    }