JSFiddle - React, Tailwind, and code Playground

HTML

<div id="myID"></div>

CSS

#myID{
	width:	200px;
	height: 100px;
	margin: 100px;
	background-color: orange;
	transform: rotate(-20deg);
	transition: 1s ease-in-out;
}

JavaScript

var i = 0;
var thesquare = document.getElementById('myID');
function FunRotate()
{
	switch(i)
	{
		case 0:
		thesquare.style.transform = 'rotate(20deg)';
		i++;
		break;
	
		default:
		thesquare.style.transform = 'rotate(-20deg)';
		i=0;
		break;
	}
}
setInterval(FunRotate, 1000);