Explaining Loop πŸ”
1.
Loop is the fundamental building block of programming, used to repeat or iterate the fixed number of steps.
Loop saves the time and labour.

Thread 🧡

#100DaysOfCode #DEVCommunity #javascript #programming #loop
2. Real time example
Suppose you are donating $100 to each one of the 50 homeless.
For that you will keep count of people who are you done with.
So, 3 things we r doing:
β€’ setting condition to 50
β€’ counting ( increment )
β€’ donating
3.
There are many ways out there to implement loop in programming:
β€’ foor loop
β€’ while loop
β€’ forEach
β€’ do while
and many, you can also develop your own.
4.
syntax or format to write the loop in programming varies as per loop we implement, but for the most common loop which is for loop is following syntax:
for( let person = 0; person < 50; person++ )
{
donate_100();
}
loop ends when 50 persons are donated $100.
5.
Consider syntax as the sentence structure for writing the programming statements.
there is a particular format predefined for every programming language to write the statement. what we call syntax in programming terms.
#DEVCommunity #100DaysOfCode
6.
forEach() loop 1/3
-It is asociated with array with a callback function once 4 every element.
-It has 3 parameters( value,index,array)with the fixed position(no matter what name u choose 4 them).
-returns undefined.
array parameter represents the actual array.
6.
forEach() loop 2/3
syntax πŸ‘‡
array.forEach(value, index, array)
{
index and array are optional.
} Image
6.
forEach() loop 3/3
another example for array parameter to understand it bit more.
βœ…array parameter prints the actual array, number of times its length is.
[1,2].forEach((value,index,array)=> console.log(array)) will print [1,2]x2 times. Image

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Akram Narejo

Akram Narejo Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(