Prompt Not Popping Up


#1

Why when var x1 is equal to false, it doesn't pop up the prompt in the else if statement.

var x1 = confirm("Press 'ok' to create another variable");
if (x1 === true) {
var x2 = confirm("Press 'ok' to create another variable");

} else if (x1 === false) {
var medi1 = prompt("Input Variable 1");// <--
var medi2 = prompt("Input Variable 2");// <--
var zedi1 = Number(medi1);
var zedi2 = Number(medi2);
var findMedi1 = function(a, b) {
var add = a + b;
//Divide by how many variables
var div = add / 2;
console.log("The Mean is " + div);
};
var addA = zedi1 + zedi2;
var divA = add / 10;
var find1 = zedi1 - div;
var find2 = zedi2 - div;
var convert1 = Math.abs(find1);
var convert2 = Math.abs(find2);
var round1 = Math.round(convert1);
var round2 = Math.round(convert2);
var add1 = (round1 + round2);
var div1 = add1 / 2;
var rangeMax1 = Math.max(zedi1, zedi2);
var rangeMin1 = Math.min(zedi1, zedi2);
console.log("The Absolute Mean Deviation is " + div1);
console.log("The largest value is " + rangeMax1);
console.log("The smallest value is " + rangeMin1);
console.log("Inputted numbers were, " + medi1 + ", " + medi2);
}


#2

@amanodude,

//Pre-define the function
var findMedi1 = function(a, b) {
   var add = a + b; 
//Divide by how many variables
   var div = add / 2;
   console.log("The Mean is " + div);
};

var x1 = confirm("1 Press 'ok' to create another variable no-Medi");
if (x1 === true) {
    var x2 = confirm("2 Press 'ok' to create another variable");
    console.log(x2);
} else if (x1 === false) {
    var medi1 = prompt("Input Variable 1");// <--
    var medi2 = prompt("Input Variable 2");// <--

    var zedi1 = Number(medi1);
    var zedi2 = Number(medi2);

    findMedi1(zedi1,zedi2);
    
    var addA = zedi1 + zedi2;
    var divA = addA / 10;  //<<====
    var find1 = zedi1 - divA;  //<<====
    var find2 = zedi2 - divA;  //<<====
    var convert1 = Math.abs(find1);
    var convert2 = Math.abs(find2);
    var round1 = Math.round(convert1);
    var round2 = Math.round(convert2);
    var add1 = (round1 + round2);
    var div1 = add1 / 2;
    var rangeMax1 = Math.max(zedi1, zedi2);
    var rangeMin1 = Math.min(zedi1, zedi2);
    console.log("The Absolute Mean Deviation is " + div1);
    console.log("The largest value is " + rangeMax1);
    console.log("The smallest value is " + rangeMin1);
    console.log("Inputted numbers were, " + medi1 + ", " + medi2);
}

#3

Thank You! That HELPED A LOT!!!