This question runs in a pre-configured Salesforce environment - no personal connection required.
Given a list of user IDs, fetch each user from the DummyJSON API and build a map of user first names to their city. The API endpoint is https://dummyjson.com/users/{id} and the response includes a "firstName" field at the top level and an "address" object containing a "city" field. Return an empty map for null or empty input. If a request fails, skip that user and continue with the next one.
The DummyJSON user response structure:
{
"id": 1,
"firstName": "Emily",
"address": {
"city": "Phoenix"
}
}
Examples:
Input: userIds = (1)
Output: {Emily=Phoenix}
Explanation: User 1 has firstName Emily and lives in Phoenix
Input: userIds = (1, 2)
Output: {Emily=Phoenix, Michael=Anytown}
Explanation: Two users fetched and mapped
Input: userIds = null
Output: {}
Explanation: Null input returns empty map
Input: userIds = ()
Output: {}
Explanation: Empty list returns empty map
Apex Code Editor
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
🏆 #CodeEveryDay August 2026
Contest runs August 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.