Catch Missing Open and Closing Parenthesis After a Function Call

Tell us what’s happening:

I just don’t really understand the task, I got confused, with how to move on.
TASK:
Fix the code so the variable result is set to the value returned from calling the function getNine

Your code so far


function getNine() {
  let x = 6;
  let y = 3;
  return x + y;
}

let result = getNine;
console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call

Found it:

function getNine() {
let x = 6;
let y = 3;
return x + y;
}

let result = getNine();
console.log(result);

Tell us what’s happening:

I’m not sure when I’m supposed to use the parentheses after a function. I believe I’ve run into this same problem in previous FCC challenges, but I ignored it hoping it would be explained at a later time. Here are my solutions to two challenges found in the Redux front end library curriculum. The first code challenge asks to dispatch an action creator and the parentheses after the loginAction() function are required to complete the challenge when it is called in the dispatch method:

Dispatch an Action Event

const store = Redux.createStore(
  (state = {login: false}) => state
);

const loginAction = () => {
  return {
    type: 'LOGIN'
  }
};

// Dispatch the action here:
store.dispatch(loginAction());

But here, the counter() function wont work when called by store.subscribe method if parentheses are added.

Register a Store Listener

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

Both cases are passing functions without parameters that produce returns so I’m confused. Are you required to invoke the action creator before it can be dispatched, but subscribe can invoke the function itself?

I posted on this thread because it seems to also display a similar situation. I believe the parentheses are required after getNine to invoke the function otherwise there is no return to store in result.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/redux/dispatch-an-action-event
https://learn.freecodecamp.org/front-end-libraries/redux/register-a-store-listener