acces to switch statement parametre value from a global variable : am learning javascript  by making a little project ,       I have little probleme of understanding well global variables , 
in that example when I put the variable = result ; from the randomvariable() function ,  on the switch parametre of  test() function  it doesn't work 

      function randomvariable () {
        var myarray = new Array;
        
        myarray = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
        randomvariable  = Math.floor(Math.random() * 0);
        result = (myarray[randomvariable]);  
        
        }
    
    function test() {
    	
    
    switch (result) {
        case 0:
            alert("haahhaha");
            break; 
    }	
    }

