From af4f7fb04d57a2696c0ff6a4a012da0fcb9a2cdc Mon Sep 17 00:00:00 2001 From: Asmadhamac Date: Thu, 14 Apr 2022 13:51:13 +0300 Subject: [PATCH] Done --- .vscode/settings.json | 3 +++ exercise.js | 54 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6b665aa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} diff --git a/exercise.js b/exercise.js index da0af63..e583815 100644 --- a/exercise.js +++ b/exercise.js @@ -1,2 +1,52 @@ -// Good Luck! You got this 💪🏾 -// Write your code here. +// // Good Luck! You got this 💪🏾 +// // Write your code here. +function describeCountry(country, population, capitalCity){ + console.log(`${country} has ${population} million people and it's capital city is ${capitalCity}`); + } + describeCountry("Somaliland", 3.5, "Hargeisa"); + describeCountry("Ethiopia", 115, "AddisAbaba"); + describeCountry("Somalia", 15, "Mogadishu"); + + function percentageOfWorld(population){ + return population / 7900 * 100 + } + let populationOfMalaysia= percentageOfWorld(32) + let populationOfSingapore= percentageOfWorld(6) + let populationOfIndonesia= percentageOfWorld(273) + + console.log(`Malaysia has 32 million people, so it's about ${populationOfMalaysia}% of the world population`); + + console.log(`Singapore has 32 million people, so it's about ${populationOfSingapore}% of the world population`); + + console.log(`Indonesia has 32 million people, so it's about ${populationOfIndonesia}% of the world population`); + + + let population= [12,40,30,55]; + for(let i=0 ; i < 4; i++){ + console.log(population[i]); + } + + let neighbours=["Algeria","Niger","Chad","Mali"] + console.log(neighbours.length === 4); + + + for(let n=0;n<4;n++){ + console.log(neighbours[n]) + } + for(let n= neighbours.length-1 ;n>0;n-- ){ + console.log(neighbours[n]) + } + + + {let n = 0 + while(n=0){ + console.log(neighbours[n]) + n-- + } + } \ No newline at end of file