I'am having trouble understanding how to write a callback function with this problem

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

// 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);

Your browser information:

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

Challenge: Register a Store Listener

Link to the challenge:

Hope this helps? if you haven’t figured it yet

  1. Create a separate function
  2. Call store.subscribe and pass the function (at which point it becomes a callback function) you created in 1 as an argument

PS: Don’t forget to increment the count value in the function in 1