JSFiddle - React, Tailwind, and code Playground

by brigand

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<script>
	
  class Timer {
  	constructor() {
    	this.id = null;
    }
    sleep(ms) {
    	clearTimeout(this.id);
      return new Promise(resolve => {
      	this.id = setTimeout(resolve, ms);
      });
    }
  }
  
	const timer = new Timer();  
  function getRandomIntInclusive(min, max) {
  		min = Math.ceil(min);
  		max = Math.floor(max);
  		return Math.floor(Math.random() * (max - min +1)) + min;
  }

	const assignData = async () => {
			document.getElementById('price1').innerHTML = getRandomIntInclusive(90,120);
    	await timer.sleep(2000);
			return await assignData();
  }
    
</script>

<body onload="assignData()">
    <h2 id="price1"></h2>

</body>
</html>