Redux - Register a Store Listener

Tell us what’s happening:
Describe your issue in detail here.
Hi everybody, I’m stuck on this challange, anyone available to explain me this topic a little better? Thank you :slight_smile:

  **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 = 1;
const addOne = () => (count += 1);

// Change code below this line
function addCount() {
console.log(count);
}
store.subscribe(addCount);
// 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_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Redux - Register a Store Listener

Link to the challenge:

You have a couple of small issues here.

First of all, follow instructions. Don’t change code where you were told not to change code. You changed the starting value for count.

You also created two callback functions (one in the wrong place). You passed the wrong one to store.subscribe.

oh thank you I got it! I don’t know what was I thinking :sweat_smile:

Cut yourself some slack. Redux is weird. Don’t get me wrong - I love it. But when you’re learning it, it’s definitely weird.