Q.
-Write a JavaScript function that:
1. Displays a confirmation box asking the user "Are you sure?" when a button
is clicked.
2. If the user confirms, display an alert saying "You confirmed."
code-
<!DOCTYPE html>
<html>
<head>
<title>Confirmation Example</title>
<script>
function confirmAction() {
let result = confirm("Are you sure?");
if (result) {
alert("You confirmed.");
}
}
</script>
</head>
<body>
<button onclick="confirmAction()">Click Me</button>
</body>
</html>