0 of 6 problems solved0%
5 of 6

Rename Without Mutation

Sometimes you’ll want to return a new object with a small change while keeping the same shape. This avoids surprising side effects in callers.

Your Task

  • Complete the function renameUser(u: { id: number; name: string }, newName: string): { id: number; name: string }.
  • Return a new object with the same id and the updated name.
  • Do not modify the input object.

Examples

  • renameUser({ id: 1, name: 'A' }, 'B') → { id: 1, name: 'B' }