How To Alert In JavaScript With Yes / No

↔️ ↕️

Sharing buttons:

in this video we're going to look at how

to create an alert in JavaScript with

yes/no options so you might already be

familiar with the alert function that

allows you to put a pop-up in a user's

browser that then disappears when they

click the ok button but the alert

function doesn't actually return any

value and you can see that in the

console here in chrome you're actually

getting an undefined value come back so

what about if you want to ask the user

if they're actually sure and then get a

yes-or-no answer and then perhaps put

that inside an if statement so you can

do something different if the user

doesn't want to proceed with the action

well we can do that with another

function called confirm

this time you can see in our alert box

we've actually got two different options