This question runs in a pre-configured Salesforce environment - no personal connection required.
Write a method findCountriesByCurrency that accepts a currency code (e.g., 'USD', 'EUR') and returns a List of country names that use that currency.
Make an HTTP GET request to the REST Countries API using the endpoint https://restcountries.com/v3.1/currency/{currencyCode} where {currencyCode} is replaced with the input parameter.
The API returns an array of country objects. Each country object contains a name field with a common property that holds the country name.
If the HTTP request fails, the API returns an error, or no countries are found, return an empty list.
Example 1: Find countries using USD
List<String> countries = findCountriesByCurrency('USD');
// Returns a list that includes 'United States', 'Ecuador', 'El Salvador', etc.
// (exact list may vary, but should include United States)
Example 2: Find countries using EUR
List<String> countries = findCountriesByCurrency('EUR');
// Returns a list of European countries that use the Euro
// (includes 'Germany', 'France', 'Spain', 'Italy', etc.)
Example 3: Invalid currency code
List<String> countries = findCountriesByCurrency('INVALID');
// Returns empty list [] because the currency code does not exist
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • This challenge runs without connecting your own org
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.