if (confirm("Press a button!")) {
console.log("Accepted")
} else {
console.log("Declined")
}
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var name = prompt("Please enter your name", "XYZ");
if (name != null) {
alert('Your name is ' + name )
}
}
</script>
</body>
</html>
// confirm, prompt, alert is popup
// confirm
confirm("Are you still alive?")
// prompt
prompt("Enter your name")
// alert
alert("You are a nice person")
// confirm is used for ask ok or cancel if person says ok then ok return true if person says cancel then it will return false
// prompt is use of asking text and it will return that text
// alert is to popup a message