how initialize global variable inside a function

how initialize global variable inside a function

var t =' ';
function k()
{
t="hello";
alert(t); // alerts hello

}

alert(t)// needs to alert hello