JSFiddle - React, Tailwind, and code Playground

by MuLtDirectX

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
</body>
</html>

CSS

.block {
   width:100px;
   height:100px;
   background: blue;
}

JavaScript

function createBlock(){
		const block = document.createElement('div')
    block.className = 'block'
   	document.querySelector('body').appendChild(block)
    	return function(){
 
          block.remove()
          console.log('Block has been removed')}
}

var myFunc = createBlock()

setTimeout(myFunc, 5000)