Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ternary operator javascript

function fee(isMember)
{
return isMember==true?"$20":"$100"
}

console.log(fee(true))

/*a==b?c:d*/
/*the syntax is check if a equals b, if so, return c otherwise return d*/
/*1==1?4:10: check if 1 equals 1, if so, return 4 otherwise return 10*/
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ternary #operator #javascript
ADD COMMENT
Topic
Name
1+6 =