Search⌘ K
AI Features

Quiz 2

Explore how to fix a Redux reducer and implement code without combineReducers in this quiz. Understand practical Redux project structuring and state management by applying key concepts learned in previous lessons.

We'll cover the following...
Technical Quiz
1.

The following code is used to implement a reducer that will accept a “SCORE_POINT” action and will increment the score of a specific team by 1

const initialState = {
  red: 2,
  blue: 1
}

const scoreReducer = (state = initialState, action) => {
  if (action.type === "SCORE_POINT") {
    return { ...state, [action.team]: state[action.team] + 1 }
  }

  return state;
}

Are there errors within the code?

A.

Yes

B.

No


1 / 2

Q3. Fix the following reducer code

Javascript (babel-node)
const reducer = (state, action) => { switch (action.type) {
case "ADD_RECIPE":
state.recipes.push({ name: action.name });
}
return state;
};

Q4. Implement the ...