console.log(countries) alert('Open the console and check if the countries has been loaded') //Exercice 01 const countries = [ 'Albania', 'Bolivia', 'Canada', 'Denmark', 'Ethiopia', 'Finland', 'Germany', 'Hungary', 'Ireland', 'Japan', 'Kenya' ] const webTechs = [ 'HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node', 'MongoDB' ] const mernStack = ['MongoDB', 'Express', 'React', 'Node']; // Exo 01 for(let i = 0; i < countries.length; i++) { console.log(countries[i]); } //backforward const words = countries.length; for(let i = words; i >= 0; i--) { console.log(countries[i]); } //while loop let i =0; while(i < webTechs.length) { console.log(webTechs[i]); i++; } //backforwar let i = webTechs.length; while(i>=0){ console.log(webTechs[i]); i--; } //do ... while loop let x = 0; do{ console.log(mernStack[x]); x++; } while(x < mernStack.length); //backforward let w = mernStack.length; do{ console.log(mernStack[w]); w--; }while(w >= 0); //exo 03 let n = 17; for(let i = 0; i 0) { console.log(isLand); } else { console.log("All these countries are withoun 'land'"); } //exo 08 let isIA = []; for(let i=0; i < countries.length; i++){ if(countries[i].toLowerCase().endsWith('ia')){ isIA.push(countries[i]); } } if(isIA.length > 0) { console.log(isIA); } else { console.log("These are countries ends without ia"); } // ['Albania', 'Bolivia', 'Ethiopia'] //exo 09 let big = ''; for(let i=0; i < countries.length; i++){ if(countries[i].length> big.length){ big = countries[i]; } } console.log(big); //exo 10 let isBig = []; for(let i=0; i longest.length){ longest = webTechs[i]; } } console.log(longest);//JavaScript //exo 12 let array1 = []; for (let i = 0; i < webTechs.length; i++){ let c = webTechs[i].length; array1.push([webTechs[i], c]); } console.log(array1); //exo 13 let accronym = ''; for (let i = 0; i < mernStack.length; i++) { accronym += mernStack[i].charAt(0); } console.log(accronym);//MERN //exo 14 for(const i of webTechs){ console.log(webTechs[i]; } //exo 15 let fruits = ['banana', 'orange', 'mango', 'lemon']; for (let i = fruits.length; i >= 0; i--) { console.log(fruits[i]); } //exo 16 const fullStack = [ ['HTML', 'CSS', 'JS', 'React'], ['Node', 'Express', 'MongoDB'] ]; for (let i = 0; i < fullStack.length; i++){ for (let j = 0; j < fullStack[i].length; j++){ console.log(fullStack[i][j]) } } //exercise level 03 const countries = [ 'Albania', 'Bolivia', 'Canada', 'Denmark', 'Ethiopia', 'Finland', 'Germany', 'Hungary', 'Ireland', 'Japan', 'Kenya', 'Malaysia' ]; // Create a copy of the array without modifying the original const copiedCountries = [...countries]; // Sort the copied array const sortedCountries = copiedCountries.slice().sort(); // Sort the webTechs array const webTechs = ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node', 'MongoDB']; const sortedWebTechs = webTechs.slice().sort(); // Sort the mernStack array const mernStack = ['MongoDB', 'Express', 'React', 'Node']; const sortedMernStack = mernStack.slice().sort(); // Extract countries containing 'land' const countriesWithLand = []; for (let i = 0; i < countries.length; i++) { if (countries[i].toLowerCase().includes('land')) { countriesWithLand.push(countries[i]); } } // Find the country with the highest number of characters let longestCountry = ''; for (let i = 0; i < countries.length; i++) { if (countries[i].length > longestCountry.length) { longestCountry = countries[i]; } } // Extract countries containing only four characters const countriesWithFourChars = []; for (let i = 0; i < countries.length; i++) { if (countries[i].length === 4) { countriesWithFourChars.push(countries[i]); } } // Extract countries containing two or more words const countriesWithMultipleWords = []; for (let i = 0; i < countries.length; i++) { if (countries[i].includes(' ')) { countriesWithMultipleWords.push(countries[i]); } } // Reverse and capitalize countries array const reversedAndCapitalizedCountries = []; for (let i = countries.length - 1; i >= 0; i--) { reversedAndCapitalizedCountries.push(countries[i].toUpperCase()); } console.log('Sorted Countries:', sortedCountries); console.log('Sorted Web Techs:', sortedWebTechs); console.log('Sorted MERN Stack:', sortedMernStack); console.log('Countries with "land":', countriesWithLand); console.log('Country with the most characters:', longestCountry); console.log('Countries with four characters:', countriesWithFourChars); console.log('Countries with multiple words:', countriesWithMultipleWords); console.log('Reversed and Capitalized Countries:', reversedAndCapitalizedCountries);