Too begin with this is not my code. I'm a beginner hobby coder with Javascript and am using a book from which this exercise came from to learn from. Unfortunately the publishers website is missing the files for the book hence my issue.
The code below should when run show the contents of the str variable. When I run it though I just get a blank browser screen. I've checked for any obvious glaring typos but can't see any. To begin with I created a html document as below
<html>
<head>
<title>Variable</title>
<script type = "text/javascript" src = "variable.js">
obj.innerHTML = str + ":" + typeof str;
</script>
<body>
<div id = "panel"> </div>
</body>
Then I typed the output code in Notepad and saved that in the same folder as the html code. I also saved the code as a Javascript file in the same place
The output code is below
function init()
{
//STATEMENTS TO BE EXECUTED GO HERE
var str = "Text Content in Javascript";
obj.innerHTML = str + ":" + typeof str;
}
document.addEventListener( "DOMContentLoaded", init, false);
From my limited knowledge of Javascript I'm guessing that the code to output the result isn't being seen but I don't understand why or more likely I'm missing something blindingly obvious. Where is the missing link?