JSFiddle - React, Tailwind, and code Playground

Reddit Writing Prompt Scrambler.

by Swordie

HTML

Need some settings but too lazy to come up with something neat? Here you go.
<br>
<br>

<button>i wanna travel to...</button>
<h2></h2>

JavaScript

$('button').click(function() {
    $('h2').text(randomEl(trope1)+', '+randomEl(trope2)+', '+randomEl(trope3));
    selectElementContents($('h2')[0]);
});

function randomEl(list) {
    var i = Math.floor(Math.random() * list.length);
    return list[i];
}

function selectElementContents(el) {
    var range = document.createRange();
    range.selectNodeContents(el);
    var sel = window.getSelection();
    sel.removeAllRanges();
    sel.addRange(range);
}

var trope1 = ["hey"];

var trope2 = ["hello"];

var trope3 = ["hi"];

$('button').click();