From c021eab8fc80bebb8c08296880ba794df2ce57c6 Mon Sep 17 00:00:00 2001 From: melmi4455 Date: Sat, 16 Apr 2022 04:50:03 +0300 Subject: [PATCH] Done --- .vscode/settings.json | 3 ++ exercise.js | 76 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/exercise.js b/exercise.js index da0af63..07bf14f 100644 --- a/exercise.js +++ b/exercise.js @@ -1,2 +1,78 @@ // Good Luck! You got this 💪🏾 // Write your code here. + +// Answer 1 + +function describeCountry(country,population,capitalCity) { + return country + " " + "has " + population + " " + "people and its Captial City is" + " " + capitalCity; +} + +let Country = describeCountry('Somaliland', '3.5 million' , 'Hargeisa' ); +console.log (Country) + + +// Answer 2 + +let Country1= describeCountry ('Ethiopia','80 million','Addis Ababa'); +let country2= describeCountry ('kenya','60 million','Nairobi'); +let country3= describeCountry ('Somalia','10 million','Mogadisho') + +console.log(Country1); +console.log(country2); +console.log(country3); + +// Answer 3 & 4 + +function percentageOfWorld1(population) { + return (population/7900)*100 +} + +let usaPopl = percentageOfWorld1(332) +let indiaPopl = percentageOfWorld1(1406) +let sudanPopl = percentageOfWorld1(43) + +console.log(`USA is about ${usaPopl}% of the worlds population` ) +console.log(`India is about ${indiaPopl}% of the worlds population` ) +console.log(`Sudan is about ${sudanPopl}% of the worlds population` ) + + +// Answer 5 + +let population = [1441,486,232,111] + +// Answer 6 & 7 +let neighbours = ["Somalia","Djibouti","Ethiopia"] + + + +console.log(neighbours.length) + +console.log( neighbours.length==4); + +// Answer 8 + + + +for(i=0;i=0;i--){ + console.log(neighbours[i]); + +} + +Answer 10 + +let i =0 +while (i=0) { + console.log(neighbours[j]); + j-- +} \ No newline at end of file