From 78240d786486e21ff9277f64394c6bbdf1941396 Mon Sep 17 00:00:00 2001 From: loic242 Date: Mon, 5 Dec 2022 00:10:49 +0200 Subject: [PATCH] Trynna run the array --- .../01_day_starter/helloworld.js | 3 +- 02_Day_Data_types/02_day_starter/main.js | 13 ++++++++- 05_Day_Arrays/05_day_starter/scripts/main.js | 29 +++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/01_Day_Introduction/01_day_starter/helloworld.js b/01_Day_Introduction/01_day_starter/helloworld.js index 8c9e2c0..b3721cf 100644 --- a/01_Day_Introduction/01_day_starter/helloworld.js +++ b/01_Day_Introduction/01_day_starter/helloworld.js @@ -1 +1,2 @@ -console.log('Hello, World!') \ No newline at end of file +console.log('Hello, World!') +//Print something with JS code. diff --git a/02_Day_Data_types/02_day_starter/main.js b/02_Day_Data_types/02_day_starter/main.js index 7762908..3572615 100644 --- a/02_Day_Data_types/02_day_starter/main.js +++ b/02_Day_Data_types/02_day_starter/main.js @@ -1 +1,12 @@ -// this is your main.js script \ No newline at end of file +// this is your main.js script + +let string = 'JavaScript' +let firstLetter = string[0] +console.log(firstLetter) // J +let secondLetter = string[1] // a +let thirdLetter = string[2] +let lastLetter = string[9] +console.log(lastLetter) // t +let lastIndex = string.length - 1 +console.log(lastIndex) // 9 +console.log(string[lastIndex]) // t diff --git a/05_Day_Arrays/05_day_starter/scripts/main.js b/05_Day_Arrays/05_day_starter/scripts/main.js index 50cc07e..3c5fa30 100644 --- a/05_Day_Arrays/05_day_starter/scripts/main.js +++ b/05_Day_Arrays/05_day_starter/scripts/main.js @@ -1,3 +1,26 @@ -console.log(countries) -alert('Open the browser console whenever you work on JavaScript') -alert('Open the console and check if the countries has been loaded') \ No newline at end of file +const numbers = [0, 3.14, 9.81, 37, 98.6, 100] // array of numbers +const fruits = ['banana', 'orange', 'mango', 'lemon'] // array of strings, fruits +const vegetables = ['Tomato', 'Potato', 'Cabbage', 'Onion', 'Carrot'] // array of strings, vegetables +const animalProducts = ['milk', 'meat', 'butter', 'yoghurt'] // array of strings, products +const webTechs = ['HTML', 'CSS', 'JS', 'React', 'Redux', 'Node', 'MongDB'] // array of web technologies +const countrie = ['Finland', 'Denmark', 'Sweden', 'Norway', 'Iceland'] // array of strings, countries + +// Print the array and its length + +console.log('Numbers:', numbers) +console.log('Number of numbers:', numbers.length) + +console.log('Fruits:', fruits) +console.log('Number of fruits:', fruits.length) + +console.log('Vegetables:', vegetables) +console.log('Number of vegetables:', vegetables.length) + +console.log('Animal products:', animalProducts) +console.log('Number of animal products:', animalProducts.length) + +console.log('Web technologies:', webTechs) +console.log('Number of web technologies:', webTechs.length) + +console.log('Countries:', countrie) +console.log('Number of countries:', countrie.length)