|
|
|
@ -60,7 +60,7 @@ for(let i = 0; i < numbers.length; i++){
|
|
|
|
|
console.log(sum) // 15
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Creating a new are based on the existing array
|
|
|
|
|
Creating a new array based on the existing array
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
const numbers = [1, 2, 3, 4, 5]
|
|
|
|
@ -74,6 +74,16 @@ for(let i = 0; i < numbers.length; i++){
|
|
|
|
|
console.log(newArr) // [1, 4, 9, 16, 25]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
const countries = ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland']
|
|
|
|
|
const newArr = []
|
|
|
|
|
for(let i = 0; i < countries.length; i++){
|
|
|
|
|
newArr.push(countries[i].toUpperCase())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(newArr) // ["FINLAND", "SWEDEN", "NORWAY", "DENMARK", "ICELAND"]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### while loop
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
@ -145,6 +155,16 @@ for (const tech of webTechs) {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
const countries = ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland']
|
|
|
|
|
const newArr = []
|
|
|
|
|
for(const country of countries){
|
|
|
|
|
newArr.push(country.toUpperCase())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(newArr) // ["FINLAND", "SWEDEN", "NORWAY", "DENMARK", "ICELAND"]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### break
|
|
|
|
|
|
|
|
|
|
content will be added soon
|
|
|
|
|