<!DOCTYPE html>
<html lang="en-US">
<body>
<p>"txt" is a local variable of "myFunction()", it can be accessed by any function within "myFunction()"</p>
<p id="point"></p>
<script>
var x = document.getElementById("point");
function myFunction(){
var txt = "Hello";
function displayText(){
x.innerHTML = txt;
}
displayText();
}
myFunction();
</script> </body>
</html>