Register a Store Listener looks right, but doesn't pass the test

Tell us what’s happening:

Your code so far


const ADD = 'ADD';

const reducer = (state = 0, action) => {
  switch(action.type) {
    case ADD:
      return state + 1;
    default:
      return state;
  }
};

const store = Redux.createStore(reducer);

// global count variable:
let count = 0; 

// change code below this line
store.subscribe (() => count++) 
// change code above this line

store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});
console.log(count);

You have an unnecessary space in your store.subscribe function call that the tester doesn’t like.

1 Like