JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<button id="do_the_magic">Find en vinder</button>
<div><span id="table">?</span>-<span id="seat">?</span></div>
JavaScript
var tables = {
'A': 28,
'B': 24,
'C': 28,
'D': 32,
'E': 32,
'F': 32,
'G': 32
}
$(function(){
$("#do_the_magic").click(function(){
var keys = Object.keys(tables);
var table = keys[Math.floor(keys.length * Math.random())];
var seats = tables[table];
var seat = Math.floor(Math.random() * seats) + 1;
setTimeout(function(){
showWinner(table, seat);
}, 2000);
//$("#output").text(winner);
});
});
function showWinner(table, seat){
$("#table").text(table);
setTimeout(function(){
showSeat(seat);
}, 2000);
}
function showSeat(seat){
$("#seat").text(seat);
}