problem using global var

problem using global var

Hello, my problem is more a javascript problem but you helped me well until today so I would like to submit it to you :

I've got this function (it is with the network information plugin of cordova) :

function onDeviceReady() { 
              conn = checkConnection();                                
              test= 3;
          }

and in another script (used later in the html page), I just wrote 

alert(test);

and the result is "undefined".

I saw on many javascript tutorials that declaring a variable without "var" make it global, but it doesn't work and I tried some other ways found on forums, but nothing did it, so I ask for your help, thank you !


PS : ask me if you need a jsfiddle, but I thought it wasn't really useful in that case