Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
76 changes: 76 additions & 0 deletions exercise.js
Original file line number Diff line number Diff line change
@@ -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<neighbours.length;i++){
console.log(neighbours[i])
}

// Answer 9

for(i<neighbours.length;i>=0;i--){
console.log(neighbours[i]);

}

Answer 10

let i =0
while (i<neighbours.length){ console.log(neighbours[i])
i++;
}

let j =2
while (j>=0) {
console.log(neighbours[j]);
j--
}