countrycodejs
Version:
Country code validation
14 lines (13 loc) • 500 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const countries_json_1 = __importDefault(require("./countries.json"));
exports.byCapital = (capital) => {
const foundCountry = countries_json_1.default.find((country) => country.capital === capital);
if (!foundCountry) {
return null;
}
return foundCountry;
};