Q:

Trying to print out JS variable in HTML

I am trying to print out the variables val1-5 in HTML. Doesn't seem to be working, any help would be appreciated.
var val1 = 0;
var val2 = 0;
var val3 = 0;
var val4 = 0;
var val5 = 0;
var fing = prompt("enter code");

window.onload = function(){
    var str = fing;
    var res = str.charAt()
    val1 = res;

    //str 2//
    var str = fing;
    var res1 = str.charAt(1)
    val2 = res1;
    var str = fing;
    var res2 = str.charAt(2)
    val3 = res2;
};
</script>

<p id="var1"></p>
<p id="var2"></p>
<p id="var3"></p>

A:

Okay, i am clueless about your end game and for some reason your code doesn't make sense but..
to print in HTML, You need to do something like.. 
document.getElementById("var1").innerHTML = val1

