JS Ternary functions with multiple conditions?

前端 未结 9 607
花落未央
花落未央 2020-12-31 04:44

I have been using a ternary operator in JavaScript to modify the value of an object based on user input. I have the following code, which runs as it should:

         


        
9条回答
  •  长情又很酷
    2020-12-31 05:04

    Yes, and it does provide a cleaner code than switch statement.. with all the breaks..

    inputOne == "Yes" ? "517" :
    inputOne == "No" ? "518" : inputOneAns = "";
    

提交回复
热议问题