Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Conditional ternary operator

function getFee(isMember) {
  return (isMember ? '$2.00' : '$10.00');
}

console.log(getFee(true));
// expected output: "$2.00"

console.log(getFee(false));
// expected output: "$10.00"

console.log(getFee(null));
// expected output: "$10.00"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Conditional #ternary #operator
ADD COMMENT
Topic
Name
7+4 =