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
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are operator is commonly used to replace if…else statement?

A

A conditional ternary operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the syntax for a ternary operator?

A

condition ? exprIfTrue : exprIfFalse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly