JSFiddle - React, Tailwind, and code Playground

by donniec

HTML

<h2>Eat, Sleep, Work</h2>
<ul>
</ul>

JavaScript

function random(min, max) {
    return Math.floor((Math.random() * max) + min);
}

function print(msg){
    var li = document.createElement('li');
    li.innerHTML = msg;
    document.querySelector('ul').appendChild(li);
}

function eat() {
    setTimeout(function() {
        print('eat');
    }, random(1, 10));
}

function sleep() {
    setTimeout(function() {
        print('sleep');
    }, random(1, 10));
}

function work() {
    setTimeout(function() {
        print('work');
    }, random(1, 10));
}

eat();
sleep();
work();