Skip to content

fikrcamp/JavaScript-fundamentals-exercises-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Functions

  1. Write a function called 'describeCountry' which takes three parameters: country,population and capitalCity. Based on this input, the function returns a string with this format: 'Somaliland has 3.5 million people and its captial city is Hargeisa'
  2. Call the function 3 times with input data for 3 different countries. store the return values in 3 different variables and log them to the console.
  3. The world population is 7900 million people. Create a function called percentageOfWorld1 which recieves a population value and reutnrs the percentage of the world population that the given population represents. For example, China has 1441 million people, so it's about 18.2% of the world population

    NOTE: To calculate the percentage, divide the given population value by 7900 and then multiply by 100

  4. Call percentageOfWorld1 for 3 populations of countries of your choice, store the results into variables, and log them to the console

Introduction to arrays

  1. Create an array containing 4 population values of 4 countries of your choice and store it in a varaible called population
  2. Create an array containing all the neighbouring countries of a country of your choice. Store the array into a varaible called neighbours
  3. Log to the console whether the array has 4 elements or not (true or false)

Iteration: for loops

  1. Console log one by one the countries inside the neighbours array.
  2. Console log one by one the countries inside the neighbours array but this time in a reverse order.

Iteration: while loop

  1. Do exercise 8 & 9 using while loop

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors