I am having a bit of trouble understanding the lifetime of global variable x below. I have commented my question on the line that I am not understanding.. please help... thanksss
var target = document.getElementById("outputArea");
var outString = "";
var x = 0;
var y = 0;
callMeOften2();
callMeOften2();
callMeOften2();
outString += "<br/>";
target.innerHTML = outString;
function callMeOften2() {
outString += x + "<br/>"; //why isn't this going to give an output of 0? but gave an output of undefined instead? isn't x referring to the global variable x?
var x = 100;
x = x + 100;
outString += "from callMeoften2: " + "x = " + x + "<br/>";
}