Skip to content
Open
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
60 changes: 58 additions & 2 deletions exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
// Good Luck! You got this 💪🏾
// Write your code here.
const desribeCountry = (country,population,capitalCity) => {
return (`${country} has ${population} million people and its captial city is ${capitalCity}`);
}

let somaliland = desribeCountry("somaliland",3.2, "hargeisa");
let japan = desribeCountry("japan",13.9, "Tokyo");
let mexio = desribeCountry("mexio",9.2, "mexioCity");

console.log(somaliland, "\n", japan, "\n", mexio);

// functions

const percentageOfWorld = (population) =>{
let popuPercantage = population / 7900 * 100;
return `_china has 1441 million people, so it's about ${popuPercantage}% of the world population_`;

}

let china = percentageOfWorld(1441);
let france = percentageOfWorld(2139907);

console.log(china, "\n", france);

// arrays

let aPopulation = ["somaliland","Turky", "canada", 'Germany'];

let neighbours = ["Djbouti","somalia", "Ethopia", "Yemen"];

console.log(neighbours);

// iteration for loops

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


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


// while loop


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


let r = neighbours.length -1;
while(i >= 0){
console.log(neighbours[i])
i--;
}