DEV Community

PUSHAN VERMA
PUSHAN VERMA

Posted on

2 1

for Loop,while loop ,do-while loop,forEach Loop and forin loop

for loop

console.log("for loop");

for(let i=0;i<10;i++)
{
console.log(i);
}

Image description

while loop

let i=0;
while(i<10)
{
console.log(i);
i++;
}
Image description

do-while loop

let i=0;
do
{
console.log(i);
i++;
}while(i<10)

Image description

forEach Loop
(used for iterate every value , it is a type of syntactic sugar , to write in a better way)

let arr2=[10,20,30,40];

arr2.forEach(function(element){
console.log(element);
})
Image description

forIn loop
(it is only used to iterate or display content present inside the object)

for(let key in obj)
{
// console.log(key);
// console.log(obj[key]);
console.log(The ${key} of the person is ${obj[key]});
}
Image description

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay