define variable in function and use outside code example
Example: change a variable outside a function js
var global = "Global Variable"; //Define global variable outside of function
function setGlobal(){
global = "Hello World!";
};
setGlobal();
console.log(global); //This will print out "Hello World"