This question runs in a pre-configured Salesforce environment - no personal connection required.

Make an HTTP GET request to the REST Countries API to retrieve the languages spoken in a given country. Use the endpoint https://restcountries.com/v3.1/name/{countryName}?fields=languages to fetch country data. Parse the JSON response and return a sorted list of language names. Return an empty list for null or blank input, if the API returns a non-200 status code, or if no languages are found.

Examples:

Input: countryName = 'Germany' Output: ['German'] Explanation: Germany has one official language, German Input: countryName = 'Switzerland' Output: ['French', 'German', 'Italian', 'Romansh'] Explanation: Switzerland has four official languages, returned in alphabetical order Input: countryName = '' Output: [] Explanation: Blank input returns an empty list Input: countryName = null Output: [] Explanation: Null input returns an empty list
Apex Code Editor

Welcome to Lightning Challenge!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay Mar/April 2026

Contest runs March 3 - April 30. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.