window.onload = function(){ addScenario = function(scenario){ let $liElement = $("
  • ") if(scenario.adult == true){ $adultText = $("

    (question for those over the age of 18... or those mature enough)

    "); $liElement.append($adultText); } $description = $("

    " + scenario.description +"

    "); $options = $(""); for(option of scenario.options){ $options.append($("
  • " + option + "
  • ")); } if (scenario.other){ $options.append("
  • Other...
  • "); } $why = $("

    Why would you choose this awnser?

    "); $whyResponse = $("") $liElement.append($description); $liElement.append($options); $liElement.append($why); $liElement.append($whyResponse); if(scenario.question){ $question = $("

    " + scenario.question + "

    "); $questionResponse = $("") $liElement.append($question); $liElement.append($questionResponse); } $("#scenarios").append($liElement); } $.getJSON("./resources/questions/scenarios.json", "", function(data){ for(const scenario of data.scenarios){ addScenario(scenario); } }); }