Jquery newbie question help with appending a variable

Jquery newbie question help with appending a variable

So I have the following function :
function getletter(){
     var letter=$.trim($(this).html());
     window.location='searchresults.php?querystring='+letter+'&querydesc=Name Like &querytype=1';
     
    }

in which i want to take the letter variable out and use it in another function to append:


$("#main h2 a").append('+letter+');

Its working if I just put in a  string but cant think of  way in order for this variable to be taken from the other function and be displayed here.