1

There exists a quiz website that requires the submission of an answer before the correct one is revealed. I did some digging into the website's JavaScript and found this function:

    function getAnswer(curCard) {
      var answer = void 0;
      if (curCard.testTerm) {
        answer = curCard.testTerm;
      } else {
        answer = curCard.choices[curCard.correctAnswerIndex];
      }
      return answer;
    }

I want to use the Chrome developer console to invoke this function but I am met with this error:

VM3133:1 Uncaught ReferenceError: getAnswer is not defined
    at <anonymous>:1:1

This function is deep within the webpage's source and the .js file itself is like 10k lines of code. I am 99% sure this is a scoping issue and do not know how to get into the proper scope so that I can call this function.

  • Welcome to SO. You might find reading the site [help section](https://stackoverflow.com/help) useful when it comes to [asking a good question](https://stackoverflow.com/help/how-to-ask). To get the best answers to your question we like to see that you've attempted to solve the problem yourself first using a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Here's a [question checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) you might find useful... – Mister Jojo Feb 09 '22 at 00:23
  • We have no way to properly assist you here without some (perhaps significant) details on where the function resides as it pertains to namespaces, things like that. – Mark Schultheiss Feb 09 '22 at 00:25
  • It's possible if you're determined, but somewhat involved. Either use a MutationObserver or Chrome Local Overrides or Fiddler. I'd suggest figuring out if there's any other way you could get to the same outcome, but sometimes that just isn't possible and hacking into the closure is the only way. – CertainPerformance Feb 09 '22 at 00:27

0 Answers0