-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasia-population-data.js
24 lines (23 loc) · 1.33 KB
/
asia-population-data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const getPopulationGrowthData = (filteredArray, indexObj, countries, populationObject) => {
if (countries.indexOf(filteredArray[indexObj.indexCountry]) > -1) {
if (filteredArray[indexObj.indexIndicatorCode] === 'SP.RUR.TOTL') {
if (populationObject[filteredArray[indexObj.indexCountry]]) {
populationObject[filteredArray[indexObj.indexCountry]].rural = filteredArray[indexObj.indexValue];
} else {
populationObject[filteredArray[indexObj.indexCountry]] = {};
populationObject[filteredArray[indexObj.indexCountry]].rural = filteredArray[indexObj.indexValue];
populationObject[filteredArray[indexObj.indexCountry]].country = filteredArray[indexObj.indexCountry];
}
} else if (filteredArray[indexObj.indexIndicatorCode] === 'SP.URB.TOTL') {
if (populationObject[filteredArray[indexObj.indexCountry]]) {
populationObject[filteredArray[indexObj.indexCountry]].urban = filteredArray[indexObj.indexValue];
} else {
populationObject[filteredArray[indexObj.indexCountry]] = {};
populationObject[filteredArray[indexObj.indexCountry]].urban = filteredArray[indexObj.indexValue];
populationObject[filteredArray[indexObj.indexCountry]].country = filteredArray[indexObj.indexCountry];
}
}
}
return populationObject;
};
module.exports = getPopulationGrowthData;