From f98141ace0f1412bf69ed70bc0498fefbcb5e858 Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:12:51 +0200 Subject: [PATCH 1/6] fix bug return value getAllCountryStateNames() --- src/functions.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/functions.js b/src/functions.js index e950414..fe578e1 100644 --- a/src/functions.js +++ b/src/functions.js @@ -42,7 +42,7 @@ exports.getCountryTimeZone = (countryName) => { exports.getAllCountryStateNames = () => { return countryStates.map((country) => { return country.states.map((states) => { - return country.name - states.name; + return country.name + "-" + states.name; }); }); }; @@ -86,7 +86,11 @@ exports.getFilteredObj = (methodType, filterObj) => { }; exports.getCountryByCode = (number) => { - let countryCode = String(number) - let getCountryCode = countryCode.split('-')[0] - return countryCallingCodes.filter((country) => country.dial_code === getCountryCode)[0] || {} -} \ No newline at end of file + let countryCode = String(number); + let getCountryCode = countryCode.split("-")[0]; + return ( + countryCallingCodes.filter( + (country) => country.dial_code === getCountryCode + )[0] || {} + ); +}; From 2d425c9359cd9254d0a60eb3fbd4846d77ca2cea Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:27:51 +0200 Subject: [PATCH 2/6] concat str --- src/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.js b/src/functions.js index fe578e1..91d2d59 100644 --- a/src/functions.js +++ b/src/functions.js @@ -42,7 +42,7 @@ exports.getCountryTimeZone = (countryName) => { exports.getAllCountryStateNames = () => { return countryStates.map((country) => { return country.states.map((states) => { - return country.name + "-" + states.name; + return concat(states.name, " (", country.name, ")"); }); }); }; From 34b2a76f7dca28278429f956c44eccc3c3a2db82 Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:28:57 +0200 Subject: [PATCH 3/6] has no attribute name --- src/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions.js b/src/functions.js index 91d2d59..ed580a2 100644 --- a/src/functions.js +++ b/src/functions.js @@ -41,8 +41,8 @@ exports.getCountryTimeZone = (countryName) => { exports.getAllCountryStateNames = () => { return countryStates.map((country) => { - return country.states.map((states) => { - return concat(states.name, " (", country.name, ")"); + return country.states.map((state) => { + return concat(state, " (", country, ")"); }); }); }; From c703d62baff6d6e14a7e9ff559e5424d9ac94790 Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:34:42 +0200 Subject: [PATCH 4/6] another try to concaternate strings :D --- src/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions.js b/src/functions.js index ed580a2..8200541 100644 --- a/src/functions.js +++ b/src/functions.js @@ -41,8 +41,8 @@ exports.getCountryTimeZone = (countryName) => { exports.getAllCountryStateNames = () => { return countryStates.map((country) => { - return country.states.map((state) => { - return concat(state, " (", country, ")"); + return country.states.map((states) => { + return states + " (" + country + ")"; }); }); }; From 55594fcd8e8dba1f1f4fc24610d8d205eec98018 Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:40:04 +0200 Subject: [PATCH 5/6] json was different --- src/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions.js b/src/functions.js index 8200541..1252dfb 100644 --- a/src/functions.js +++ b/src/functions.js @@ -41,8 +41,8 @@ exports.getCountryTimeZone = (countryName) => { exports.getAllCountryStateNames = () => { return countryStates.map((country) => { - return country.states.map((states) => { - return states + " (" + country + ")"; + return country.states.map((state) => { + return state + " (" + country.country + ")"; }); }); }; From dbf7bc6c8883b458e7219fab173e56b8db39c7f7 Mon Sep 17 00:00:00 2001 From: mister-mon <126079855+mister-mon@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:46:53 +0200 Subject: [PATCH 6/6] flatmap states --- src/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.js b/src/functions.js index 1252dfb..48c1446 100644 --- a/src/functions.js +++ b/src/functions.js @@ -40,7 +40,7 @@ exports.getCountryTimeZone = (countryName) => { }; exports.getAllCountryStateNames = () => { - return countryStates.map((country) => { + return countryStates.flatMap((country) => { return country.states.map((state) => { return state + " (" + country.country + ")"; });