I am starting a new mini series on JavaScript. I’m starting it from zero. Anyone can start learning from here. My goal is helping others while learning! I know about JavaScript and I’m working on a MERN tech stack. But I think it is not a bad idea to revise the JavaScript from scratch and helping others in this time. If you have any questions, shoot on the comment session or you can directly ask me in my social media. Social media links are in the last part of today’s lesson! Let’s learn JavaScript together.

Loops — JavaScript Series — Part 12

A full series to learn the JavaScript from zero

Muhammad Ali
2 min readFeb 1, 2020

We are going to learn a really important topic today. I know this one is overwhelming at first, but if you practice then you’ll get this properly! Don’t just see the post of today, work on it too!

There are some different kind of loop in js but all they do the same work
for — loops through a block of code a number of times
for/in — loops through the properties of an object
for/of — loops through the values of an iterable object
while — loops through a block of code while a specified condition is true
do/while — also loops through a block of code while a specified condition is true
(w3schools)

Most popular is for and while. We’ll learn both in your practice.

Sometimes we need to do the same task again and again. Like for adding sum of 10, 12 and 30 we need to add all these. First we need to work 10 + 12 then 22 + 30 again right ? Or we can add all three at a time, but suppose there is huge numbers like 500 numbers. What to do ?

We need to go through each and every number and add that to our total value. Which is going start from zero right?

We can do this work by loop. We can remove the doing same task again and again by using loop.

Lets see this

Understand something ?

We’ll work on loop code next tutorial.

Originally it published on nerdjfpb blog. Check the git for codes.

you can connect with me in twitter, linkedin or instagram

--

--

Muhammad Ali
Muhammad Ali

Written by Muhammad Ali

An otaku who loves computer. Love to write and help others through my work. Have a look on my Instagram https://www.instagram.com/nerd_jfpb/

No responses yet