What do you think is wrong with this code as it currently is written?
Currently, this function is going to divide everything by 0 - which, if you remember you elementary school math, is not allowed. It’s undefined. Click to continue to see what happens in JavaScript.
Can you see something wrong with the function as currently written?
function doMath() {
var x = 2
var y = 10
var answer = x * y / z;
var z = 4;
document.getElementById("output").innerHTML = "The result is " + answer;
}The answer variable is being declared before the variable z has been defined, which isn’t possible. What do you think will happen? Click to continue and find out.
note