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
we've got okay and council and if we
click okay you can see the confirm
function returns a true value if you try
that again and click cancel this time we
get a false value returned so the okay
button is equivalent to true and the
cancel button gives us a false value
back so we could capture the result of
the confirm function into a variable and
then we've got it to use in other parts
of our JavaScript code
you
so you might be asking how can I change
the okay in Council text to yes or no or
or some other positive and negative
combination of words and the simple
answer is that it really isn't possible
to change those values the exact text
that you'll get will also depend on what
browser your user is running and in
reality the browsers built-in alert and
confirm dialog boxes aren't really that
pretty and as you've seen they're not
really that flexible so if you did
really want to truly customize that
experience for the user you're probably
better off creating your own modal
pop-up which consists of HTML elements
I'm triggered by JavaScript so that you
can customize any of that text and
behavior to see the project that you're
working on but if you just after a quick
confirmation from the user you can use
the confirm function
you