break
Description
Will exit the loop (forLoop/whileLoop)
Input / Parameter
N/A
Output
N/A
Callback
N/A
Example
In this example, we will do console logging by using console function in forLoop function callback to demonstrate how break works.
Code Equivalent
for (let i = 1; i < 10; i++) {
console.log(i);
if (i == 5) {
// Exit the loop
break;
}
console.log("some text")
}Steps
Drag a
buttoncomponent into the canvas and open theActiontab. Select thepressevent of the button and drag theforLoopfunction to the event flow, add the value1onstartparam and add the value9onendparam.
Drag the function
consoleto theforLoopfunction yes callback, on it'svalueparam change the param type to input.
Drag the function
conditionalinside functionforLoopyes callback, on paramconditionchange the param type to subflow/function. Inside paramconditionsubflow addequalfunction then on it'svalue1param change the param type to input and on it'svalue2param add value5.
Drag the function
breakinside functionconditionalyes callback.
Drag the function
consoleafter functionconditional, add valuesome texton it'svalueparam.
Result
Now click the button in preview, it will show the list current loop number along with
some textfive times on the console before thebreakfunction stop the loop.
Links
Related Information
See also:
Functions
Last updated