How to get a variable through several functions in js?

Hi all, I have this js code

var rand = 8;

function(){
func_1();
}

func_1(){
func_2();
}
func_2(){
 if(rand == 8){
$("#id").hide();
}
}


Can not seem to get the variable in function 2,
How can I get the variable rand in func_2 ?
June 3rd 19 at 19:23
1 answer
June 3rd 19 at 19:25
It is not entirely clear what you want, but think it does not hurt to declare the functions.

var rand = 8;

var name = function(){
func_1();
}();

function func_1(){
func_2();
}
function func_2(){
 if(rand == 8){
$("#id").hide();
}
}

Find more questions by tags JavaScript