confirm function
The confirm function calls up
a confirmation box with OK and
Cancel buttons. Returns
true if the OK button
was pressed, and false if the
Cancel button was pressed. The
parameter takes the text that the
user will see.
Syntax
confirm(message);
Example
Let's use the confirm function to
display a dialog box. If you press OK
in the box that appears, then true
will be written to the variable res,
and if you press Cancel - then
false:
<button id="button">click me</button>
let button = document.querySelector('#button');
button.addEventListener('click', function(event) {
let res = confirm('Are you 18 years old?');
console.log(res);
});
: