JSFiddle - React, Tailwind, and code Playground

HTML

<script>function earlyOne(){alert("woah, I am early...")}</script>

<!-- Not going to work -- no scope of alertMe() -->
<input type="button" onclick="alertMe()" value="attempt to call alertMe">

<!-- Will work, no reference to the alertMe, just alert -->
<input type="button" onclick="alert('yo')" value="attempt to call alert">

<!-- Will work, early one is referenced above -->
<input type="button" onclick="earlyOne()" value="attempt to call earlyOne">

<!-- Will be binded in the JavaScript -->
<input id="alert_button" type="button" value="attempt to call alertMe w/ event listener">

JavaScript

function alertMe() {
	alert("yo!")
}

document.getElementById("alert_button").addEventListener("click", function(){
	alertMe();
})