I couldn’t understand why it send the nan when I pass more arguments than parameters
JavaScript
x
11
11
1
function percetageofworld3(population1) {
2
return (population1 / 7900) * 100;
3
}
4
const describePopulation = function(country, population) {
5
const chinesePopulation = percetageofworld3(country, population);
6
console.log(chinesePopulation)
7
const countries = `${country} has ${population} million people,
8
which is about ${chinesePopulation}% of the world`
9
return countries;
10
}
11
Advertisement
Answer
You pass into percetageofworld3
two parameter but the function have just one, so you pass country for example ‘italy’ and it will be return ('italy' / 7900) * 100;
If you pass only number work
JavaScript
1
11
11
1
function percetageofworld3(population1) {
2
return (population1 / 7900) * 100;
3
}
4
const describePopulation = function(country, population) {
5
const chinesePopulation = percetageofworld3(population);
6
console.log('Result of chinesePopulation: ' + chinesePopulation)
7
const countries = `${country} has ${population} million people,
8
which is about ${chinesePopulation}% of the world`
9
return countries;
10
}
11
console.log('Result of describePopulation: ' + describePopulation('italy', 1000))