JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Javascript Example</h1>
<div id="output"></div>
JavaScript
(function(){
/* all of our stuff is hidden inside
this anonymous function ...
a common javascript idiom to make
sure that variable names don't collide
between different .js files */
var output = $('#output'); /* the output div */
var content = ''; /* text inside output */
function printline(something){
/* add this text to content,
and redisplay the output div */
content = content + something + '<br>'
output.html(content);
}
/* Let's print a list of numbers
in a loop. */
for (var i=0; i<10; i++){
printline(i);
}
var numbers = [10, 11, 12];
printline(numbers);
})();