Quiz 2

Test your knowledge of the content learned up till now.

We'll cover the following...
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

Question 1 of 20 attempted

Q3. Fix the following reducer code

Press + to interact
const reducer = (state, action) => { switch (action.type) {
case "ADD_RECIPE":
state.recipes.push({ name: action.name });
}
return state;
};

Q4. Implement the ...