I have defined a variable named var1 inside the function in javascript but could not access it outside the function. I have referred several solutions in which I got this method to define global variable but it is not accessible outside the function.
function msg1(a) {
window.var1=a;
}
document.getElementById("scores").innerHTML=var1;