JSFiddle - React, Tailwind, and code Playground

by nevkatz

HTML

<div id="root">

</div>

JavaScript

let article = {
  intro:'Intro text.',
  conclusion:'Concluding text.'
}
// pseudo-randomly generate either a 0 or a 1.
let randomNum = Math.round(Math.random());
// determine which property to pull based on this number.
let myProp = (randomNum == 1) ? 'intro' : 'conclusion';
// get the property.
let val = article[myProp];

let root = document.querySelector('#root');

root.textContent = val;