Loops/While: Difference between revisions

m
Line 740:
}</lang>
 
In a functional idiom of JavaScript, however, we can not use a loopWhile '''statement''' to achieve this task, as statements return no value, mutate state, and can not be composed within other functional expressions.
 
Instead, we can define a composable loopWhile() '''function''' which has no side effects, and takes 3 arguments:
:#An initial value
:#A function which returns some derived value, corresponding to the body of the While loop
:#A conditional function, corresponding to the While test
 
<lang JavaScript>function loopWhile(varValue, fnDelta, fnTest) {
9,655

edits