var CorrectAnswers = {
  "question1": "question1_answer_3",
  "question2": "question2_answer_1",
  "question3": "question3_answer_2",
};

var correct_page = {
  "question1": "correct_page",
  "question2": "correct_page_2",
  "question3": "correct_page_3",
};

var incorrect_page = {
  "question1": "incorrect_page",
  "question2": "incorrect_page_2",
  "question3": "incorrect_page_3",
};

var screenButtons =
{
  "question1" : 4,
  "question2" : 4,
  "question3" : 4
};
 


setAnswerButtonEvent();

onEvent("start_button", "click", function( ) {
  console.log("Start Button Clicked");
  setScreen("question1");
  });

function setAnswerButtonEvent(){
  var keys = Object.keys(screenButtons);
  console.log(keys);
  Object.keys(screenButtons).forEach(function (key) {
    var buttonCount = screenButtons[key];
    for(var i=1; i <= buttonCount; i++) {
      var answerButtonName = key + "_answer_" + i;
      console.log(answerButtonName);
      checkAnswer(key, answerButtonName );  
    }
  });
}

function checkAnswer(question, choice ){
  onEvent(choice, "click", function(event) {
    console.log(choice + " is clicked!");
    
    if (CorrectAnswers[question] !== choice ) {
      setScreen(incorrect_page[question]);
    } else {
      console.log("correct page");
      setScreen(correct_page[question]);
    }
   });
}
onEvent("correct_continue_button_1", "click", function( ) {
  console.log("Correct Continue Button Clicked");
  setScreen("question2");
  });
 
onEvent("incorrect_continue_button_1", "click", function( ) {
  console.log("Incorrect Continue Button Clicked");
  setScreen("question2");
  });
  
  onEvent("correct_continue_button_2", "click", function( ) {
  console.log("Correct Continue Button Clicked");
  setScreen("question3");
  });
 
onEvent("incorrect_continue_button_2", "click", function( ) {
  console.log("Incorrect Continue Button Clicked");
  setScreen("question3");
  });
 
 onEvent("correct_continue_button_3", "click", function( ) {
  console.log("Correct Continue Button Clicked");
  setScreen("finish_page");
  });
 
onEvent("incorrect_continue_button_3", "click", function( ) {
  console.log("Incorrect Continue Button Clicked");
  setScreen("finish_page");
  });
[ 'question1', 'question2', 'question3' ]
question1_answer_1
evalmachine.<anonymous>:49
  onEvent(choice, "click", function(event) {
  ^

ReferenceError: onEvent is not defined
    at checkAnswer (evalmachine.<anonymous>:49:3)
    at evalmachine.<anonymous>:43:7
    at Array.forEach (native)
    at setAnswerButtonEvent (evalmachine.<anonymous>:38:30)
    at evalmachine.<anonymous>:28:1
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at run ([eval]:1020:15)
    at onRunRequest ([eval]:864:18)
    at onMessage ([eval]:828:13)