Conditionals Flashcards
1
Q
What is the syntax for conditionals?
A
if(condition is ture){ //do this }else if(this is true){ //do this }else{ //do this }
2
Q
What are conditional (ternary) operator?
A
It is an operator that takes in 3 operands: a condition followed by a question mark (?) then an expression to execute the condition if it is truthy followed by a colon (:) and the expression to execute if the condition is falsy.
3
Q
What are operator is commonly used to replace if…else statement?
A
A conditional ternary operator
4
Q
What is the syntax for a ternary operator?
A
condition ? exprIfTrue : exprIfFalse
5
Q
What is the definition of ‘truthy’ and ‘falsy’?
A
‘Truthy’ value is a value that is equal or can be converted to true
‘Falsy’ is a condition that has a value which can be converted to false