Updating Global Variables
Posted: Sun Mar 23, 2008 2:10 pm
I have two javascript functions defined below:
Instead of display() displaying "hello world", it says that the variable is undefined
Why is it that str is not updated before document.write() is called?
Code: Select all
var str
function display()
{
setStr()
document.write(str)
}
function setStr()
{
str = "hello world"
}Why is it that str is not updated before document.write() is called?