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!

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.