function myFunc(){
alert("test this");
}
In your HTML file include script tag referencing that file
<script src="main.js"></script>
<button onclick="myFunc()">Click Me</button>
Or just do the following for a quick test:
<button onclick="alert(`test me`)">Test Me</button>