JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

JavaScript

var id;

/**
 * Continually replicates interval ids with setInterval
 */
var repeat = function() {
    if ( id !== 1 ) {
        console.log('id: %d', id);
        clearInterval( id );
        id = setInterval( repeat, 50 );
    } else {
        clearInterval( id );
        alert('id is 1');
    }
};

repeat();