freeCodeCamp / freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free.
https://contribute.freecodecamp.org
BSD 3-Clause "New" or "Revised" License
404.04k stars 37.78k forks source link

Getting an error message ( in console ) on submitting the correct solution #50865

Open AnonSar opened 1 year ago

AnonSar commented 1 year ago

Describe the Issue

When the user submits the correct solution for the Register a Store Listener module, then they end up with the following error message within the console:

Build error, open your browser console to learn more.

Given that the user is submitting the correct solution ( since all the unit tests are getting passed and // tests completed is getting printed in the console ), then showing such an error message ( along with other messages ) to the user could make them feel a bit confused.

Affected Page

https://www.freecodecamp.org/learn/front-end-development-libraries/redux/register-a-store-listener

Your code

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
function incrementCount(){
  return count++;
}
store.subscribe(incrementCount());
// 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);

Expected behavior

In order to avoid any sort of ambiguity and to keep things as clear as possible, I believe when the user submits their solution and if their submitted solution is entirely correct, then they should be getting the following messages only ( within the console ):

// running tests // tests completed

Screenshots

image

System

ojeytonwilliams commented 1 year ago

Hi, @AnonSar, thanks for the report. The code you shared does have a small bug - it should be

store.subscribe(incrementCount); // not incrementCount()

since subscribe expects to be passed a function.

That said, there are a few things going wrong in the client:

AnonSar commented 1 year ago

Ah I see, looks like I totally missed that bit, thanks for pointing that out @ojeytonwilliams ! Appreciate it 🙏 !

Shubhdeep02 commented 1 year ago

hey!!! @AnonSar Is the issue still open ????