ternary function code example
Example 1: ternary operator
(condition) ? (if true, do this) : (otherwise, do this)
Example 2: javascript ternary operator
var isOpen = true;
var welcomeMessage = isOpen ? "We are open, come on in." : "Sorry, we are closed.";
Example 3: Ternary Operator
condition ? expression-if-true : expression-if-false;
function findGreater(a, b) {
return a > b ? "a is greater" : "b is greater";
}
Example 4: javascript ternary
condition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
Example 5: ternary operator
if ($scope.SearchSalesOrderAndCompanyName !== undefined && $scope.SearchSalesOrderAndCompanyName != null ) {
SearchCriteria += " AND [SalesOrderNo] LIKE '%" + $scope.SearchSalesOrderAndCompanyName + "%' OR ([SO].[CompanyNameOnBill] LIKE '%" + $scope.SearchSalesOrderAndCompanyName + "%')";
}
if ($scope.FromDate !== undefined && $scope.FromDate !=null) {
SearchCriteria += " AND [SO].[SalesOrderDate] LIKE '%" + $scope.FromDate + "%'";
}