iT邦幫忙

2021 iThome 鐵人賽

DAY 17
0

To fully understand how loop works, I try to break down the loop and practice like below.

1+2+........+50 Arithmetic Operations

var sum=0;
var n=1;
while(n<=200){
    sum=sum+n; → sum+=n
    n++;
}
alert(sum);

https://ithelp.ithome.com.tw/upload/images/20210915/20130362I9mbC7FAKo.png


continue: command and execution

var x=0;
for(var i=0;i<200;i++){
    if(i%4==0){ → i can be divided exactly by 4.
        continue;
    }
    x++;
}
alert(x);

https://ithelp.ithome.com.tw/upload/images/20210915/20130362MNTRrvPhl4.png


Music of Today: If Only by Andrea Bocelli & aMEI

Yes


Like/Share/Follow

Feel free to comment and share your ideas below to learn together!
If you guys find this article helpful, please kindly do the writer a favor — LIKE this article./images/emoticon/emoticon12.gif


上一篇
#16 JS: loop - Part 1
下一篇
#18 JS: Intro to function
系列文
Learn & Play JavaScript -- Entry-Level Front-End Web Development30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言