How to 'output' a JavaScript variable into an HTML div
html, javascript
Solution
Working code is here
Write your script in `body`.
Code
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>Have 7 output here</div>
<script type="text/javascript">
var ball = 3+4;
document.getElementsByTagName('div')[0].innerHTML = ball;
</script>
</body>
</html>
Problem
I have a JavaScript variable and I want the HTML div to output 7. I know it's simple, but I can't seem to get my head around this. ``` <!DOCTYPE html> <html> <head> <script type="text/javascript"> var ball = 3+4; </script> </head> <body> <div>Have 7 output here</div> </body> </html> ```