Answers for "js ternary else if multi"

3

Use Multiple Conditional Ternary Operators Javascript

// Use Multiple Conditional Ternary Operators Javascript.


function checkSign(num) {

	return num > 0 ? "positive" : num < 0 ? "negative" : "zero";

}

console.log(checkSign(10));
console.log(checkSign(-10));
console.log(checkSign(0));
Posted by: Guest on January-03-2021
1

js ternary else if multi

var foo = (
  bar === 'a' ? 1 : // if 
  bar === 'b' ? 2 : // else if 
  bar === 'c' ? 3 : // else if
  null // else 
);
Posted by: Guest on May-15-2021
0

multiple ternary operator javascript

var icon = (area == 1) ? icon1 : (area == 2) ? icon2 : icon0;
Posted by: Guest on July-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language