How do you The callback to store.subscribe should also increment the global count variable as the store is updated

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

const ADD = 'ADD';

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

const store = Redux.createStore(reducer);

// Global count variable:
let count = 1;
const addOne = () => (count += 1);
// Change code below this line

// Change code above this line

store.dispatch({type: ADD});
store.dispatch({type: ADD});
store.dispatch({type: ADD});
  **Your browser information:**

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

Challenge: Register a Store Listener

Link to the challenge:

you successfully created a function which increments count by one, when called. Now you need to pass it to the store.subscribe method as a callback and everytime an action is dispatched to the store, the callback function to increment count will also be called. Passing it as a callback is very similar to passing callback to a map method for example(its actually identical^^).

1 Like

Thank you so much, this really helped.

Please can you send me your full code let me see it. Thanks