Skip to content

Commit 2a969f3

Browse files
committed
Adding country name filtering on cli command
1 parent 3c5d697 commit 2a969f3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/corona.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function getDataByCountry(confirmed, deaths, recovered) {
2828
const confirmedMap = _.keyBy(confirmed.locations, (i) => i.country + i.province);
2929
const recoveredMap = _.keyBy(recovered.locations, (i) => i.country + i.province);
3030
const deathsMap = _.keyBy(deaths.locations, (i) => i.country + i.province);
31-
const countryName = process.argv[2].toLowerCase();
31+
const countryName = process.argv[2];
3232

3333
confirmed.locations.forEach(obj => {
3434
const countryName = obj.country;
@@ -66,7 +66,7 @@ function getDataByCountry(confirmed, deaths, recovered) {
6666
const countryArr = extraStats(
6767
Object.keys(countryMap).map(key => countryMap[key])
6868
);
69-
const countryData = (countryName) ? countryArr.filter(obj => obj.country.toLowerCase() === countryName) : _.sortBy(countryArr, (o) => -o.confirmed);
69+
const countryData = (countryName) ? countryArr.filter(obj => obj.country.toLowerCase() === countryName.toLowerCase()) : _.sortBy(countryArr, (o) => -o.confirmed);
7070

7171
return countryData;
7272
}

0 commit comments

Comments
 (0)