JSFiddle - React, Tailwind, and code Playground

by javajosh

HTML

<h1>Goal: encode a Set board as a string</h1>
<p>A set board is a list of ~7 bit numbers (to encode a number up to 81), usually about 12-15 numbers long. 84 bits in hex is 21 characters.</p>

<button class="start">start</button><br>
<button class="stop">stop</button><br>
<button class="add">add</button><br>

<pre class="state"></pre>

JavaScript

var state = {i: 0, timerID: null};

function start(){
    state.timerID = setInterval(function(){
        add();
    });
    display();
}
function stop(){
    if (state.timerID) {
        clearInterval(state.timerID);
        state.timerID = null;
    }
    display();
}
function add(){
    state.i++;
    display();
}
function display(){
    $('.state').text(JSON.stringify(state, null, 2))
}

$('.start').click(start);
$('.stop').click(stop);
$('.add').click(add);

display();