From e14b51c09e30a5f84ebf2c9a16c7d9ce00a64e4f Mon Sep 17 00:00:00 2001 From: Asabeneh Date: Mon, 6 Jan 2020 23:36:13 +0200 Subject: [PATCH] day 6 --- 06_Day/06_day_loops.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/06_Day/06_day_loops.md b/06_Day/06_day_loops.md index a761360b..3dff718b 100644 --- a/06_Day/06_day_loops.md +++ b/06_Day/06_day_loops.md @@ -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