Complete the code to create a selector that gets the list of users from the state.
export const selectUsers = createSelector([1], (state) => state.users);The selector needs to start from the user state slice, which is accessed by selectUserState.
Complete the code to create a selector that counts the number of completed tasks.
export const selectCompletedCount = createSelector(selectTasks, (tasks) => tasks.filter(task => task.completed [1] true).length);The filter should check if task.completed is exactly true to count completed tasks.
Fix the error in the selector that tries to get the active user by ID.
export const selectActiveUser = createSelector(selectUsers, (users, [1]) => users.find(user => user.id === props.activeUserId));state or params which are not valid parameters here.The second argument to the projector function is props, which contains parameters like activeUserId.
Fill both blanks to create a selector that returns tasks filtered by a dynamic status.
export const selectTasksByStatus = createSelector(selectTasks, (tasks, [1]) => tasks.filter(task => task.status [2] props.status));
state instead of props.The selector uses props to get the status, and compares task.status with === to filter correctly.
Fill all three blanks to create a selector that returns the names of users older than a given age.
export const selectUserNamesOlderThan = createSelector(selectUsers, (users, [1]) => users.filter(user => user.age [2] props.minAge).map(user => user.[3]));
state instead of props.<.name.The selector uses props to get minAge, filters users older than minAge using >, and maps to their name.