How to create a dialog with “yes” and “no” options How to create a dialog with “yes” and “no” options javascript javascript

How to create a dialog with “yes” and “no” options


You’re probably looking for confirm(), which displays a prompt and returns true or false based on what the user decided:

if (confirm('Are you sure you want to save this thing into the database?')) {  // Save it!  console.log('Thing was saved to the database.');} else {  // Do nothing!  console.log('Thing was not saved to the database.');}