JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" value="reset count up to 6">

JavaScript

function countdown(counter) {
	    x = counter;
	    if (x > 0) {
	        x--;
	        alert(x + "/5");
	        if (x > 0) {
	            setTimeout(function () {
	                countdown(x);
	            }, 2000);
	        }
	    }
	};

	countdown(6);