JSFiddle - React, Tailwind, and code Playground

by Town

HTML

<div>one</div>
<div>two</div>
<div>three</div>
<div>four</div>

CSS

div {display: none;}

JavaScript

var visibleCount = 0;

/* $('div').each(function() {
    if (visibleCount >= 2) { return false; }
    alert("vc " + visibleCount);
    var r = Math.floor(Math.random() * 2);
    alert("r " + r);
    visibleCount = visibleCount + r;
    r === 0 ? $(this).hide(): $(this).show();
});
*/

var divs = $('div').get().sort(function() {
    return Math.round(Math.random()) - 0.5;
}).slice(0, 2);

$(divs).show();