How can give OR condition with IF condition in html RRS feed

  • Question

  • User-1355965324 posted

    I am trying to give OR condition to the existing IF condition of HTML

    var isdisabled = false
    var isNaDisbled = true
    // Here I want to give isEnabled = isdisabled || isNaDisbled  to given statement below
    var  isEnabled  = isdisabled  ? "disabled" : null;

    Monday, May 17, 2021 1:03 PM


  • User475983607 posted

    There are two basic programming constructs you are struggling with.  The first is understanding basic logical operators.   Truth tables are covered in even beginning level programming computer science class.   You are also struggling with the JavaScript ternary operator which is a short hand for an "if statement".

    var isdisabled = false
    var isNaDisbled = true
    var  isEnabled = isdisabled | isNaDisbled
    var result = isEnabled  ? "disabled" : null;

    The result of the ternary operator above is either the string "disabled" or null.  Please read the reference documentation rather than guessing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 17, 2021 1:25 PM