Max Call Stack Limit Using Conditional Logic with IF

Tell us what’s happening:

HELLO - I believe I have figured out the correct JAVA Syntax below, but now I am
NOT able to SUBMIT IT due to this “Max Call Stack Size LImit Error” that keeps
POPPING up?

Is it me or FCC ??
Thank you for any assistance.
UM

Your code so far


// Example
function ourTrueOrFalse(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

  // Only change code below this line.
  function trueOrFalse(wasThatTrue) {

     if (wasThatTrue)trueOrFalse(true) 
        return "Yes, that was true";
 
     if (wasThatTrue)trueOrFalse(false)
        return "No, that was false";
 } 
trueOrFalse(true); // returns "Yes That Was true";
trueOrFalse(false); // returns "No, It Was false"
  
  // Only change code above this line.

// Change this value to test
trueOrFalse(true);
}
  
  
  // Only change code above this line.



// Change this value to test

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-conditional-logic-with-if-statements

You mean JavaScript? Looks like your syntax is wrong though.

You don’t have this variable declared anywhere else. You also have duplicate function declarations

No, this is not correct, you’re calling the function which calls the function which calls the function and so on until the maximum memory the browser is allowed runs out.

So when your function gets called, like trueOrFalse(true), the second line is the function itself being called, so it just runs trueOrFalse(true) over and over until there’s no memory. The stuff you put deeper in the function is also wrong, you’re calling the function itself again, but those lines don’t matter as much because they never get reached.

The solution is to literally change the sentences in the example very slightly. There shouldn’t really be anything to figure out about syntax: what you’ve written is not like the example at all, but it should be almost identical

After working on this problem for far too long, I discovered that it was far easier than I EVER thought it would be based on the INSTRUCTIONS that FCC gives in the problem,

HENCE, this is THE PROBLEM!

FCC convolutes and confuses rather than teaches in many instances, not ALL, but many, such as this one, where the problem is SO EASY, but FCC turns the explanation into a LOOP, thus why there have been so many Max Call Stack Limits being used in attempts to SOLVE such an EASY PROBLEM.

Thank you all, I appreciate your help.
UM