#17 JS: loop - Part 2

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


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


<<:  Day 5【JavaScript】可以看到,将近是20公分的深度

>>:  [Day 02] - Mongo DB环境建置

Day14 vue.js注册验证帐号是否重复ep2

延续昨天 今天的目标是把注册功能完善! 这是昨天的console.log 来试试看 把id(帐号)设...

来举例一下 Neo4j 的实务应用

前情提要 最後一篇正篇,稍稍回顾了一下之前的每一篇 发现对於现实上的使用案例,好像没有太多的描述 所...

Day8:如果怎样就怎样

在讲else、elif之前,先来让我们看看什麽是"if" 程序码如下: [In]...

Day 27 | 等待的时间不无聊 - loader

今天想要分享的是这一个 Youtube 影片做出来的等待画面, 我只有挑他的其中一个写, 其他可以看...

[Day 08] Kotlin DAO 其他和资料库互动的方式

昨天我们看过了使用 Kotlin DAO 进行资料库 CRUD 的方式。 今天我们来看看,除了基本的...