Issue: Once I assign the document.getElementById function to a variable then invoke it I get the error above. Full Code below But if I replace var $docid = document.getElementById to var $docid = (id) => document.getElementById(id); the html page is able to grab the quiz id and render it the proper question parts (the radio choices and input text and such) The reason I bring this up is because this goes against a basic functionality in javascript which is assigning functions to variables to be able to invoke. Nothing about document.getElementById() claims the need for arrow function usage. Can anyone explain?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form id="get_quiz">
</form>
<br>
<form id="qbank">
</form>
<br>
<button type="submit" onclick="submit_quiz()">Submit Questions</button>
<button type="submit">Release Scores</button>
<button type="submit" onclick="add_question()">Add Question</button>
<button type="submit" onclick="view_qbank()">View Qbank</button>
</body>
<script>
var $docid = document.getElementById;
var x = 0;
function add_question() {
x++;
$docid('get_quiz').innerHTML += `
<h1>Question ${x}</h1>
<br>
<textarea id="${x}" rows=1 cols=100></textarea>
<br>
<p><strong>Constraints</strong></p>
<input type ='radio' id="if${x}"> If statement </input>
<input type ='radio' id="while${x}"> While Loop </input>
<input type ='radio' id="for${x}"> For Loop </input>
<br>
<br>
<input type = 'radio' id="easy${x}" name="difficulty">Easy </input>
<input type = 'radio' id="medium${x}"
name="difficulty">Medium</input>
<input type = 'radio' id="hard${x}" name="difficulty">Hard</input>
<br>
<p><strong>Test Case</strong></p>
<input type="text" id="param${x}" placeholder="parameters"></input>
<input type="text" id="return${x}" placeholder="expected value">
</input>
`;
}