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.
You can see the graphical version here
Source Codes - { Check commits }
nerdjfpb / javaScript-Series
A tutorial for JavaScript Beginners
javaScript-Series
A tutorial for Absolute Beginners of JavaScript.
You can find the total pdf in - Here
You can check the commits to find the part by part codes.
Blogs
Day 1
- Day 1 - What is JavaScript?
Day 2
- Day 2 - JavaScript Types?
Day 3
- Day 3 - Javascript Types Cont.
Day 4
- Day 4 - Javascript Types Cont.
Day 5
- Day 5 - Javascript Comparisons
Day 6
- Day 6 - Javascript Variables
Day 7
- Day 7 - More About Variables
Day 8
- Day 8 - Conditional Statement
Day 9
- Day 9 - More Conditional Statement
Day 10
- Day 10 - Switch
Day 11
- Day 11 - Setup Code Editor
Day 12
- Day 12 - Loops
Day 13
- Day 13 - While Loop
Day 14
- Day 14 - For Loop
Day 15
- Day 15 - For Vs While
Day 16
- Day 16 - Functions
Day 17
Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin!
Top comments (0)