Loops In JavaScript:
Loops in JavaScript are a way to repeat a block of code multiple times.
Types of Loops in JavaScript :
1. for
2. while Core Loops
3. do-while
4. for-of (arrays, strings, maps or sets [don’t care about index])
5. for-in (iterating over the properties (keys) of an object or the indexes of an array)
for loop
while loop
Note:
❑ Avoid infinite loop
do-while loop
for-of loop
for-in loop
Challenge 1:
Solution:
Challenge 2:
Solution:
1. Calculate sum of first ‘n’ numbers.
2. Calculate the sum of numbers from ‘m’ to ‘n’.
3. Print all odd numbers from 0 to ‘n’.
4. Create a “Number Knock” game. (ask the user to keep guessing the number
until the user enters correct guess) .
5. Simple Password Checker (Fixed Attempts)
6. Create a program to find the factorial of ‘n’.
7. Print the following pattern. (build it for nth numbers)
Build a Simple Text-Based Adventure Game