The If...Then...Else operator. Allows you to execute either one block of code or another, depending on the condition. If you need more options, use helper.switch.
For example, if you want to conduct a survey, you can use the helper.if
component to ask the gender of the respondent and add different sets of questions, depending on whether the respondent is male or female.
How it works:
If the condition in if
is true (returns true
), the code specified in the then
property will be executed. Otherwise (the condition is false and returns false
) the code specified in else
will be executed.
The else
property is optional. For example, you ask a Toloker "do you like the image?". You can make a comment field appear when a negative response is selected. And if a positive response is selected then nothing happens.
To learn more about conditions, see the List of conditions.
View exampleName | Type | Description |
---|---|---|
type * | "helper.if" | Set component type. |
condition * | condition | Condition to check. |
else | any | The element that is returned if the condition from the condition property is false (returns false ). |
then * | any | The element that is returned if the condition from the condition property is true (returns true ). |
Last updated: March 29, 2023