Please i need a help to fix this challenge

** I have done the challenge after runing it , the result show that i have 3 marks out of the total 4 marks ** And this is what the running test result says ( The callback to store.subscribe should also increment the global count variable as the store is updated. )
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;
  default:
    return state;
}
};

const store = Redux.createStore(reducer);

// Global count variable:
let count = 1;
const addOne = () => (count += 1);
// Change code below this line
function sayHi() {
console.log("Hi!");
}
store.subscribe(sayHi);
// 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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Challenge: Register a Store Listener

Link to the challenge:

The count should start at 0 and you should subscribe using the addOne function.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.