I can\'t find a recommended way to stop a function part way when a given condition is met. Should I use something like exit or break?
exit
break
I am
Use a try...catch statement in your main function and whenever you want to stop the function just use:
try...catch
throw new Error("Stopping the function!");