mardi 15 mai 2018

Nested Ternary Operator

"194BB" == i ? (n = 30, o = "Rs. 10,000/-") : "194C" != i || "ri" != t && "huf" != t ? "194C" != i || "ri" == t && "huf" == t ? "194D" == i ? (n = 5, o = "Rs. 15,000/- in FY"):console.log("Out")

Can someone verify the if-else interpretation of these nested ternary operators in JavaScript?

Here's my solution:

if (i === "194B"){
      n = 30;
      o = "Rs. 10,000/-";
else if (i !== "194C" || t !== 'ri' || t !== "huf"){
     if (i !== "194C" || t === 'ri' || t === "huf"){
          if (i === "194D"){
                n = 5; o = "Rs. 15,000/- in FY";
          }
          else {
               console.log("out");
          }
     }
}

Aucun commentaire:

Enregistrer un commentaire