#4 Javascript Loops| Javascript Hindi Course For Beginners ( 2023 )
Why we use Loops ?
We use loops to do repeated actions.
Types of loops in Javascript
- while
- do-while
- for
- forEach()
- map()
- for…in
- for…of
While Loop
while loop is most basic loop in javascript.
While loop runs a code block , as long as condition is true.
Do While Loop
Do-while loop is slightly different from while loop.
Its has only one feature extra.
Do While loop code is executed at least once if condition satisfies .
If condition satisfies the code block will be executed like while loop.
For Loops
For loops and while loop work exactly same.
But For loops have much advance than while loop.
you can add
initialization
in for loop directlyyou can add
condition
in for loopyou can also add
final-expression
in for loopIn case of while loop . you can only add
condition
Currently we are skipping this topics , after learning object and array we will learn it
forEach()
map()
for…in
for…of
Questions:
- Print Even number upto 60 using for loop
- Given a number n Calculate the factorial of the number
- Write table for 19 using loop
- Write a program that will allow someone to guess a four digit pin exactly 4
times. If the user guesses the number correctly. It prints “That was
correct!” Otherwise it will print “Sorry that was wrong.” Program stops after the 4th attempt of if they got it right.
Javascript Loops | Javascript Hindi Course For Beginners ( 2023 ) Complete Notes of JS - https://dosomecoding.com/courses/javascript/javascript-hindi-course-for-beginners Javascript Beginners Playlist Link - https://www.youtube.com/playlist?list=PLPppPPmk0i3gZCY8JZ0H5oykFGevvNzNS Linkedin - https://linkedin.com/in/anshuopinion Telegram Channel - https://telegram.me/dosomecodinghelp Instagram - https://instagram.com/dosomecoding Github - https://github.com/anshuopinion HTML Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gL2isb9Kr1GvTM8id2gdtY CSS Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gWK5TVILnKSvuc9Fc15sbH Html and CSS practice Projects https://www.youtube.com/playlist?list=PLPppPPmk0i3hZCNmbVtcP1hlwDKOdUFX9 Javascript Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gZCY8JZ0H5oykFGevvNzNS Linkedin - https://linkedin.com/in/anshuopinion Telegram Channel - https://telegram.me/dosomecodinghelp Instagram - https://instagram.com/dosomecoding Github - https://github.com/anshuopinion