Description
The if function allows for conditional evaluation of an expression. Based on a specified condition, the function returns one value if the condition is met (true) or another value if the condition is not met (false).
Syntax
if(condition, valueTrue, valueFalse)
Arguments
| Argument | Description |
condition |
The condition to be evaluated. If the condition is true, valueTrue is returned; otherwise, valueFalse is returned. |
valueTrue |
The value returned if the condition is true. |
valueFalse |
The value returned if the condition is false. |
Return Types
The function returns either valueTrue or valueFalse, depending on the result of the condition.
Example
if(Score > 50, "Pass", "Fail")
The example if(Score > 50, "Pass", "Fail") checks the condition Score > 50.
- If
Scoreis greater than 50, the function returns "Pass". - If
Scoreis 50 or lower, the function returns "Fail".
Result: The function returns either "Pass" or "Fail", depending on the value of Score.
Comments
0 comments
Please sign in to leave a comment.