How do you confirm a dialog?


#1

how do you confirm a dialog?


#2

When you click ok or cancel when using the prompt dialog to let your program know what the user wants.

In situations like below:

 function getConfirmation(){
           var retVal = confirm("Do you want to continue ?");
           if( retVal == true ){
              console.log("User wants to continue!");
              return true;
           }
           else{
              console.log("User does not want to continue!");
              return false;
           }
        }

#3

by using e.g.

confirm("Text");

where "Text" is the message that the user sees in the pop-up box. If you press ok this means true if you press cancel this means false and this true or false value can be used either in a condition or stored in a variable.

@devfox maybe use an example that is runable :smile:


#4

Fixed it! :stuck_out_tongue_winking_eye:


#5

Ok, thank you. Also maybe get rid of the document.write as this track is console only. Also: