[Learning]#17 JS: loop — Part 2

Vida Lin
Oct 5, 2021

--

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);

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);

Sign up to discover human stories that deepen your understanding of the world.

--

--

Vida Lin
Vida Lin

Written by Vida Lin

PM, Relationship, Travel, or anything quirky but interesting.|Subscribe & buy Vida a drink @LikerLand, the bottom of each article. 在文章底下LikerLand訂閱、請Vida喝一杯飲料 ❤

No responses yet

Write a response