Counter with Redux , can not pass quiz

Hello everyone , I wroten a little program to count the state with redux, but it do not counting when I dispatch the action. Who can help me find mistacke?

https://www.freecodecamp.org/learn/front-end-libraries/redux/write-a-counter-with-redux

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

const counterReducer = (state=0,action)=>{
      switch(action.type) {
    case 'INCREMENT':
      return state++
    case 'DECREMENT':
      return state--
    default:
      return state;
  }
}; // define the counter reducer which will increment or decrement the state based on the action it receives

const incAction = ()=>{
    return {
        type:INCREMENT
    }
}; // define an action creator for incrementing

const decAction = ()=>{
    return {
        type:DECREMENT
    }
}; // define an action creator for decrementing

const store = Redux.createStore(counterReducer); // define the Redux store here, passing in your reducers
console.log(store.dispatch(incAction()));

Hello Quintis,

Just as a reminder: Switch statements in JavaScript require the break keyword, at the end of each case.

Also, tip: Sometimes, especially in React (do not ask me why), it helps to avoid the ++ syntax, and just stick with variable += 1

Hope this helps.

1 Like

Thank you , but still do not working(