Skip to content

Commit 15154d8

Browse files
committed
command line functions body
1 parent cbe44e0 commit 15154d8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bin/country-lang.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@ case undefined:
1313
console.log("No parameters given. -h or --help for usage instructions.");
1414
break;
1515
default:
16-
if (matrix[country] === undefined) {
16+
if (matrix.filter(function (x) {
17+
return x.country === country;
18+
}).length === 0) {
1719
console.log("Country not found.");
1820
break;
1921
}
2022
switch (language) {
2123
case undefined:
22-
console.log(matrix[country]);
24+
console.log(matrix.filter(function (x) {
25+
return x.country === country;
26+
}).shift().languages);
2327
break;
2428
default:
25-
console.log(matrix[country].indexOf(language) > -1 ? true : false);
29+
console.log(matrix.filter(function (countries) {
30+
return countries.country === country;
31+
}).filter(function (countryLang) {
32+
return countryLang.languages == language;
33+
}).length > 0 ? true : false);
2634
}
2735
}
28-

0 commit comments

Comments
 (0)