Preventing code from returning false on the third variable+


#1

How do I make this code not return false on the top when I am clicking the variables above the second one?

confirm("Welcome!");
confirm("Press 'ok' to create a second variable.");
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 findMedi2 = function(a, b, c) {
   var add = a + b + c; 
//Divide by how many variables
   var div = add / 3;
   console.log("The Mean is " + div);
};


var x1 = confirm("(2 variables) Press 'ok' to create another variable. Press 'cancel to input numbers.");
if (x1 === true) {
    var x2 = confirm("(3 variables)Press 'ok' to create another variable. Press 'cancel' to input numbers.");
    console.log(x2); if(x2 === true) {
        
var x3 = confirm("(4 variables) Press 'ok' to create another variable. Press 'cancel' to input numbers.");

if(x3 === true){
    
var x3 = confirm("(5 variables) Press 'ok' to create another variable. Press 'cancel' to input numbers.");
    
    
} else if(x3 === false) {
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}




    } else if(x2 === false) {
    
    var medi1 = prompt("Input Variable 1");// <--
    var medi2 = prompt("Input Variable 2");// <--
    var medi3 = prompt("Input Variable 3");// <--
    
    var zedi1 = Number(medi1);
    var zedi2 = Number(medi2);
    var zedi3 = Number(medi3);
    
    var add1 = zedi1 + zedi2 + zedi3;
    var div1 = add1 / 3;  //<<====        
    
    var find1 = zedi1 - div1;  //<<====
    var find2 = zedi2 - div1;  //<<====   
    var find3 = zedi3 - div1;  //<<====
    
    var convert1 = Math.abs(find1);
    var convert2 = Math.abs(find2);    
    var convert3 = Math.abs(find3);    

    var round1 = Math.round(convert1);
    var round2 = Math.round(convert2);    
    var round3 = Math.round(convert3);    
    
    var add2 = (round1 + round2 + round3);
    var div2 = add2 / 3;
    
    var rangeMax = Math.max(zedi1, zedi2, zedi3);
    var rangeMin = Math.min(zedi1, zedi2, zedi3);
    var range = rangeMax - rangeMin;
    console.log("The range is " + range);
    console.log("The Absolute Mean Deviation is " + div2);
    console.log("The largest value is " + rangeMax);
    console.log("The smallest value is " + rangeMin);
    console.log("Inputted numbers were, " + medi1 + ", " + medi2 + ", " + medi3);
    findMedi2(zedi1, zedi2, zedi3); 
    
    
    }
    
    
} 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 add1 = zedi1 + zedi2;
    var div1 = add1 / 2;  //<<====
    var find1 = zedi1 - div1;  //<<====
    var find2 = zedi2 - div1;  //<<====
    var convert1 = Math.abs(find1);
    var convert2 = Math.abs(find2);
    var round1 = Math.round(convert1);
    var round2 = Math.round(convert2);
    var add2 = (round1 + round2);
    var div2 = add2 / 2;
    var rangeMax = Math.max(zedi1, zedi2);
    var rangeMin = Math.min(zedi1, zedi2);
    var range = rangeMax - rangeMin;
    var range = rangeMax - rangeMin;
  
    console.log("The range is " + range);    
    console.log("The Absolute Mean Deviation is " + div2);
    console.log("The largest value is " + rangeMax);
    console.log("The smallest value is " + rangeMin);
    console.log("Inputted numbers were, " + medi1 + ", " + medi2);
    findMedi1(zedi1, zedi2);

}