Check for an empty array?

Sugarcube 2.36.1

Players enter a maze. Since I do not know what path they may take, I’m using array.pop() to print statements on every nth turn. The problem is, once the array is depleted, [undefined] is printed. The documentation indicates that is the expected behavior. I’m not sure how to stop printing once the array is empty. I have tried an IF condition, but [undefined] still prints. Any suggestions?

<<if $maze.turns lte 15>>
 <<= $maze.stmt>>
<</if>>

Thank you in advance,
Deborah

<<if $array.length is 0>> might be something you were looking for?

(SugarCube is based on JavaScript :stuck_out_tongue: )

1 Like

Thanks!