or getFunction(id) value )

Executes the function and tests the value it returns. If you specify no value, it yields success if the return value is 0, null, undefined or false.

NOTE: remember that the expression you pass as the test value is executed at the very beginning of the experiment. So calling getFunction(“myFunction”) ) will test that the function returns the timestamp corresponding to the beginning of the experiment. In this case, you may consider rewriting your function so it takes care of testing and returns true or false in consequence.


[js highlight=”10,11″ try=”true”]newFunction(“timestampMultipleOfThree”, () => % 3 )
newText(“missed”, “Bad luck, try again!”)
newButton(“myButton”, “Click me”)
.success( getText(“missed”).remove() )
.failure( getText(“missed”).print() )

Adds a button to the screen whose clicks are validated only if happening at a time when the timestamp is not a multiple of 3 (i.e., the modulo value returned by the function is different from 0).