Functions Calling Other Functions
Create a function called
describePopulation. Use the function type you like the most. This function takes in two arguments:countryandpopulation, and returns a strings like this:'China has 1441 million people, which is about 18.2% of the world'.To calculate the percentage,
describePopulationcalls thepercentageOfWorld1you created earlier.Call
describePopulationwith data for 3 countries of your choice.
const describePopulation = function(country, population) {
const percentage = percentageOfWorld1(population);
const description = `${country} has ${population} million people, which is about ${percentage}% of the world.`;
console.log(description);
};
describePopulation('Portugal', 10);
describePopulation('China', 1441);
describePopulation('USA', 332);