From 6e6951604e819586ef581d72c0ef6b820ec45636 Mon Sep 17 00:00:00 2001 From: Guleid0 Date: Thu, 14 Apr 2022 17:36:30 +0300 Subject: [PATCH 1/2] done --- exercise.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/exercise.js b/exercise.js index da0af63..1980313 100644 --- a/exercise.js +++ b/exercise.js @@ -1,2 +1,61 @@ // Good Luck! You got this 💪🏾 // Write your code here. +function describeCountry(Country, Population, Capitalcity) { + return `${Country} has ${Population} people and its capitalcity is ${Capitalcity}` + + +} +console.log(describeCountry('Somaliland', 3.500000, 'Hargeisa')) + +//2 +let descJapan = describeCountry('Japan', 125, 'Tokyo'); + +let descBelguim = describeCountry('Belguim', 12, 'Brussels'); +let descFrance = describeCountry('France', 67, 'Paris'); +console.log(descJapan, descBelguim, descFrance); + + + +//3&4 +function percentageOfWorld3(population) { + return (population / 7900) * 100; +} +let percentageOfWorld1 = function (population) { + return (population / 7900) * 100; +}; +let percEthiopia = percentageOfWorld1(115); +let percChina = percentageOfWorld1(1441); +let percJapan = percentageOfWorld1(125); +console.log(percEthiopia, percChina, percJapan); + +//5 +let populations = [16, 115, 56, 4]; +let neighbours = ['somalia', 'Ethiopia', 'Kenya','somaliland']; +let populations4 = [16, 115, 56, 12]; console.log(populations.length === 4); + +//8 +let listOfNeighbours = ['somali', 'Ethiopia', 'Kenya', 'somaliland']; +for (let i = 0; i = 0; i--){ + console.log(listOfNeighbours[i]) +} + +//10 +let listOfNeighbours1 = ['somali', 'Ethiopia', 'Kenya', 'somaliland']; +let i = 0; +while (i <4) { + console.log(listOfNeighbours1[i]) + i++; +} + +// reverse order while loop +let x = 3; +while (x>= 0) { + console.log(listOfNeighbours1[x]) + x-- +} + From 3b1ad817d5850a2bcac93490aa3d3ef95083b992 Mon Sep 17 00:00:00 2001 From: GuleidAbdi Date: Fri, 15 Apr 2022 09:54:28 +0300 Subject: [PATCH 2/2] javascript fundamental exercise --- exercise.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercise.js b/exercise.js index 1980313..c039a22 100644 --- a/exercise.js +++ b/exercise.js @@ -34,28 +34,28 @@ let neighbours = ['somalia', 'Ethiopia', 'Kenya','somaliland']; let populations4 = [16, 115, 56, 12]; console.log(populations.length === 4); //8 -let listOfNeighbours = ['somali', 'Ethiopia', 'Kenya', 'somaliland']; -for (let i = 0; i = 0; i--){ +for (let i = SONeighbours.length -1 ; i >= 0; i--){ console.log(listOfNeighbours[i]) } //10 -let listOfNeighbours1 = ['somali', 'Ethiopia', 'Kenya', 'somaliland']; +let SONeighbours1 = ['somali', 'Ethiopia', 'Kenya', 'somaliland']; let i = 0; while (i <4) { - console.log(listOfNeighbours1[i]) + console.log(SONeighbours1[i]) i++; } // reverse order while loop let x = 3; while (x>= 0) { - console.log(listOfNeighbours1[x]) + console.log(SONeighbours1[x]) x-- }