This question runs in a pre-configured Salesforce environment - no personal connection required.
Given a user ID, fetch that user todos from the DummyJSON API and return a summary string formatted as "Total: X, Completed: Y, Pending: Z" where X is the total number of todos, Y is the count of completed todos, and Z is the count of not-completed todos. Return "Invalid User" for null, zero, or negative user IDs. Return "No Todos" if the user has no todos.
The API endpoint is: https://dummyjson.com/todos/user/{userId}
The API response format is:
{
"todos": [
{"id": 1, "todo": "...", "completed": true, "userId": 1},
{"id": 2, "todo": "...", "completed": false, "userId": 1}
],
"total": 2,
"skip": 0,
"limit": 2
}
Examples:
Input: userId = 1
Output: 'Total: 5, Completed: 3, Pending: 2'
Explanation: User 1 has 5 todos, 3 completed and 2 not completed
Input: userId = null
Output: 'Invalid User'
Explanation: Null user ID is not valid
Input: userId = 0
Output: 'Invalid User'
Explanation: Zero is not a valid user ID
Input: userId = -5
Output: 'Invalid User'
Explanation: Negative user IDs are not valid
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 July 2026
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.