ternary expression

Solutions on MaxInterview for ternary expression by the best coders in the world

showing results for - "ternary expression"
Paula
02 Jan 2021
1if (true)
2	printf("This is the shorthand");
3
4// OR
5
6(true) ? (/*run if true*/) : (/*run if false*/);
Alessandra
17 Jan 2021
1(condition) ? (if true, do this) : (otherwise, do this)
Serena
07 Jan 2021
1condition ? ifTrue : ifFalse
Amelie
21 Jan 2017
1condition ? doThisIfTrue : doThisIfFalse
2
31 > 2 ? console.log(true) : console.log(false)
4// returns false
Edwina
20 Nov 2018
1String year = credits < 30 ? "freshman" : credits <= 59 ? "sophomore" : credits <= 89 ? "junior" : "senior";
Ayoub
24 Nov 2019
1var age = 26;
2var beverage = (age >= 21) ? "Beer" : "Juice";
3console.log(beverage); // "Beer"
4
similar questions
queries leading to this page
ternary expression