dropbear-software / baller-form

Campaign sign up form implemented as a self-contained web component
MIT License
0 stars 0 forks source link

Create a function that takes in a list of countries and returns a sorted and deduplicated list #2

Open mark-dropbear opened 11 months ago

mark-dropbear commented 11 months ago

We will need this for the country level drop downs. We will need to include the following countries:

Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Poland, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden

mark-dropbear commented 11 months ago

Maybe something like this would work:

function deduplicateAndSortStrings(array: string[]): string[] {
  // Create a Set to store the unique elements of the array.
  const uniqueSet = new Set(array);

  // Convert the Set back to an array and sort it alphabetically.
  const uniqueSortedArray = [...uniqueSet].sort();

  // Return the deduplicated and sorted array of strings.
  return uniqueSortedArray;
}