Introduction to Arrays
Create an array containing 4 population values of 4 countries of your choice. You may use the values you have been using previously. Store this array into a variable called
populations.Log to the console whether the array has 4 elements or not (
trueorfalse).Create an array called
percentagescontaining the percentages of the world population for these 4 population values. Use the functionpercentageOfWorld1that you created earlier to compute the 4 percentage values.
const populations = [10, 1441, 332, 83];
console.log(populations.length === 4);
const percentages = [
percentageOfWorld1(populations[0]),
percentageOfWorld1(populations[1]),
percentageOfWorld1(populations[2]),
percentageOfWorld1(populations[3])
];
console.log(percentages);