JSFiddle - React, Tailwind, and code Playground

by maitrungduc1410

HTML

<!DOCTYPE html>
<h1 id="count">
Count: 0
</h1>
<button onclick="start()">
Start
</button>
<div id="log">
Log:
</div>
<script>
"use strict";

let count = 0
setInterval(() => {
	document.getElementById('count').innerHTML = `Count: ${++count}`
}, 1000)

function start() {

  let i = 0;

  let start = Date.now();

  function count() {

    // do a heavy job
    for (let j = 0; j < 2e9; j++) {
      i++;
    }

    document.getElementById('log').innerHTML = "Log: Done in " + (Date.now() - start) + 'ms'
  }

  count();
}
</script>