Redux: I can't register a store listener

Tell us what’s happening:
For some reason, I can’t pass the last test for this challenge.
I honestly don’t understand that much of which is happening. Can you please help me and explain it to me?
Thanks

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.ADD = function(){
count+=1;
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);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Register a Store Listener

Link to the challenge:

you to need to write a callback function for store.subscribe(callback function here) that will increment the value of a global variable named ‘count’;

1 Like

Thanks. I fixed it. That was very helpful.