DEV Community

Dinesh G
Dinesh G

Posted on

My Java Full Stack Journey Learning in JavaScript

Day six class in JavaScript. I shared the topics, What I learn Today.

LOOPING
Loops are handy, if you want to run the same code over and over again, each time with a different value.

let count=0
if (count<5){
console.log(i);
count ++;
}
Enter fullscreen mode Exit fullscreen mode

while statement
The while loop loops through a block of code as long as a specified condition is true.

let count=0
while (count<5){
console,log(i);
count++;
}
Enter fullscreen mode Exit fullscreen mode

while

1*2
2*3
3*4
4*5
.
.
.
.`
10

eg:

let i=1;
while(i<=10)
{
log(i*(i+1))
i++;
}

1_100=div by 2or3

let i=1;
while(i<=100)
{
6%2==0 6%3==0
if(i%2==0||i%3==0)
{
log(i);
}
i++;
}

eg:
let i = 0;
while(i<=8){
console.log(i);
i+=2;
}

output:
0
2
4
6
8

HAPPY CODING

Top comments (0)