Write a Counter with Redux problem

Tell us what’s happening:

Why isn’t this code passing the tests? I can’t see the error.

Thanks in advance

Your code so far

const INCREMENT = 'INCREMENT'; // define a constant for increment action types
const DECREMENT = 'DECREMENT'; // define a constant for decrement action types

const defaultState= {
    counter: 0
const counterReducer = (state=defaultState,action) => {
    switch (action.type) {
        case INCREMENT:
            return {counter:state.counter+1};
        case DECREMENT:
            return {counter:state.counter-1};
            return defaultState;

const incAction = () => {
   return {
       type: INCREMENT

const decAction = () => {
    return {
        type: DECREMENT
const store = Redux.createStore(counterReducer);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

Take another look at what you are returning for default in your switch statement…

It asks to set state value to 0 so you dont need to declare defaultState or replace state = defaultState.counter or you can declare simply state = 0 in counterReducer and
in cases return state value

1 Like

Instead of state=defaultState, try state=defaultState.counter