Not sure if I am obtaining the correct object in the following javascript code:
<form>
What is 5 + 5?: <input type ="number" id ="num_answer;"/>
</form>
<script>
function basic_math(){
var num_val = document.getElementById('num_answer').value;
if (num_val == 10) {
document.getElementById('num_answer').style.backgroundColor = green;
}
else{
document.getElementById('num_answer').style.backgroundColor = red;
}
}
</script>
<button type = "button" onclick ="basic_math();"> Solve!
</button>
The error that I am getting:
Uncaught TypeError: Cannot read property 'value' of null