jeudi 22 août 2019

How to print out statements

I am trying to get the function to print statements that fall in line with code but it is saying that some numbers that are not represented are printing out the size instead of N/A

I have used || or and &&

var shirtWidth = 23;
    var shirtLength = 30;
    var shirtSleeve = 8.71;
    
    // Write your if/else code here

    if (shirtWidth===18 || shirtWidth <20 && shirtLength===28 || shirtLength < 29 && shirtSleeve===8.13 || shirtSleeve <8.38 ){
    
    console.log("S");
    
    }else if (shirtWidth===20 || shirtWidth<22 && shirtLength===29 || shirtLength <30  && shirtSleeve===8.38 || shirtSleeve <8.63){
    
    console.log("M");
    
    }else if (shirtWidth===22 || shirtWidth <24 && shirtLength===30 || shirtLength <31 && shirtSleeve===8.63 || shirtSleeve < 8.88){
    
    console.log("L");
    
    }else if (shirtWidth===24 || shirtWidth <26 && shirtLength===31 || shirtLength < 33 && shirtSleeve===8.88 || shirtSleeve < 9.63){
    
    console.log("XL");
    
    }else if (shirtWidth===26 || shirtWidth < 28 && shirtLength===33 || shirtLength<34 && shirtSleeve===9.63 || shirtSleeve < 10.13){
    
    console.log("2XL");
    
    }else if (shirtWidth===28 && shirtLength===34 && shirtSleeve===10.13){
    
    console.log("3XL");
    
    }else{
    
    console.log("N/A");
    
    }

Expected shirtWidth of 18, shirtLength of 29, and shirtSleeve of 8.47 to log the size N/A, but received S

Aucun commentaire:

Enregistrer un commentaire