Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop.
Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop.
In programming languages to carry out repetitive task we use different kinds of loop. The following examples are the commonly used loops.
In programming languages to carry out repetitive task we use different kinds of loops. The following examples are the commonly used loops in JavaScript and other programming languages.
The above code stops if 3 found in the iteration process.
### continue
### continue
content will added soon
We use the keyword *continue* to skip a certain iterations.
```js
for(let i = 0; i <= 5; i++){
if(i == 3){
continue
}
console.log(i)
}
// 0 1 2 4 5
```
🌕 You are so brave, you made it to this far. Now, you have gained the power to automate repetitive and tedious tasks. You have just completed day 6 challenges and you are 6 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
🌕 You are so brave, you made it to this far. Now, you have gained the power to automate repetitive and tedious tasks. You have just completed day 6 challenges and you are 6 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
@ -298,16 +331,16 @@ content will added soon
7. Use for loop to iterate from 0 to 100 and print only even numbers
7. Use for loop to iterate from 0 to 100 and print only even numbers
8. Use for loop to iterate from 0 to 100 and print only odd numbers
8. Use for loop to iterate from 0 to 100 and print only odd numbers
9. Use for loop to iterate from 0 to 100 and print only prime numbers
9. Use for loop to iterate from 0 to 100 and print only prime numbers
10. Use for loop to iterate from 0 to 100 and print and print the sum of all numbers.
10. Use for loop to iterate from 0 to 100 and print the sum of all numbers.
```sh
```sh
The sum all numbers is 5050.
The sum of all numbers from 0 to 100 is 5050.
```
```
11. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.
11. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.
```sh
```sh
The sum of all evens is 2550. And the sum of all odds is 2500.
The sum of all evens from 0 to 100 is 2550. And the sum of all odds from 0 to 100 is 2500.
```
```
12. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds. Print sum of evens and sum of odds as array
12. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds. Print sum of evens and sum of odds as array
@ -378,41 +411,41 @@ content will added soon
]
]
```
```
1. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'All these are countries without land'.
2. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'All these countries are without land'.
```sh
```sh
['Finland', 'Iceland']
['Finland', 'Iceland']
```
```
1. In above countries array, check if there is a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'ai', print 'These are countries ends without ia'.
3. In above countries array, check if there is a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'ai', print 'These are countries ends without ia'.
```sh
```sh
['Albania', 'Bolivia','Ethiopia']
['Albania', 'Bolivia','Ethiopia']
```
```
1. Using the above countries array, find the country containing the biggest number of characters.
4. Using the above countries array, find the country containing the biggest number of characters.
```sh
```sh
Ethiopia
Ethiopia
```
```
1. Using the above countries array, find the country containing only 5 characters.
5. Using the above countries array, find the country containing only 5 characters.
```sh
```sh
['Japan', 'Kenya']
['Japan', 'Kenya']
```
```
1. Find the longest word in the webTechs array
6. Find the longest word in the webTechs array
1. Use the webTechs are to create the following array of arrays:
7. Use the webTechs array to create the following array of arrays:
1. An application created using MongoDB, Express, React and Node is called a MERN stack. Create the acronym MERN by using the array mernStack
8. An application created using MongoDB, Express, React and Node is called a MERN stack app. Create the acronym MERN by using the array mernStack
1. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items.
9. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items.
1. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method.
10. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method.
1. Print all the elements of array as shown below.
11. Print all the elements of array as shown below.