innerHTML not displaying
<p>Apologies for asking such a trivial question (just learning how JS works) but I am getting a headache for next to nothing. Maybe I am tired and just don't see what I am doing but why is the below not working - i.e. value of totalBits to print in the body of the 'print' div? If I alert() it shows the value but not using the innerHTML.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;script type="text/javascript"&gt;

function answer(sentence){

var bitsOfString = sentence.split(" ");
var numOfBits = bitsOfString.length;
return numOfBits;
}

var sentence = prompt("OK, say something!")
var totalBits = answer(sentence);
var div = document.getElementById("print");
div.innerHTML = totalBits;

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="print"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
