Forum Discussion
AustinK
6 years agoQrew Commander
I could try and explain it but I think an example from somewhere else is probably the best. There are several ways but they all basically do the same thing, its more like explicit vs implicit.
var txt;
var r = confirm("Press a button!");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
That is one way.
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
There are more in the links below.
https://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm
Also this one https://www.w3schools.com/jsref/met_win_confirm.asp
var txt;
var r = confirm("Press a button!");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
That is one way.
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
There are more in the links below.
https://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm
Also this one https://www.w3schools.com/jsref/met_win_confirm.asp