Approach: To show an alert on the browser window, we make a button. When we click on the button, a click event listener is called that calls a function. In that function, we use the alert() method that contains a message for the user. When we click the button, the alert window will pop up on the browser window that contains a message or warning with a button.
Below is the implementation of the above approach: