How can I solve this problem right now even with the solution provided

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 = 0;

// 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 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: Register a Store Listener

Link to the challenge:

These tests are failing:

There should be a listener function subscribed to the store using store.subscribe .

The store.subscribe should receive a function.

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

This is explained in the problem description:

Write a callback function that increments the global variable count every time the store receives an action, and pass this function in to the store.subscribe() method. You’ll see that store.dispatch() is called three times in a row, each time directly passing in an action object. Watch the console output between the action dispatches to see the updates take place.

I don’t see where you’ve tried to do that. Is that clear what you need to do?

1 Like