I'm trying to create a button so that when clicked, a specific element stored in an associative array will get deleted. But what I've done doesn't seem to work. Any help will be appreciated.
// Creates the button
bodyText = bodyText + '<input type="button" id="btnDeleteQuestion"
value="Delete a question">';
document.getElementById("btnDeleteQuestion")
.addEventListener("click", function() {
// Deletes the third question stored in the questionBank
delete questionBank[2]['questionText'];
console.log(questionBank);
});
}