If you declare a variable outside of a function, it becomes global. If you have problems, you can attach the variable to the window.
function dog() { window.myvalue = "Yay it works"; } and check it by alert(window.myValue);
function dog() { window.myvalue = "Yay it works"; }
alert(window.myValue);