JSFiddle - React, Tailwind, and code Playground

by vaibhav2812

HTML

<button>
Start machine
</button>
<p>
  the machine is stopped
</p>

JavaScript

var btn = document.querySelector('button');
var txt = document.querySelector('p');
const START_MACHINE = 'start machine';
const STOP_MACHINE = 'stop machine';
btn.addEventListener('click', updateBtn);

function updateBtn() {
  if (btn.textContent === START_MACHINE) {
    btn.textContent = STOP_MACHINE;
    txt.textContent = 'The machine is started';
  } else {
    btn.textContent = START_MACHINE;
    txt.textContent = 'The machine is stopped';
  }
}

var random = ['tree', 795, [0, 1, 2]];
random.flatten((a) => console.log(a));