How to Limit Code Generation with Codex

So I am trying to generate code but both code DaVinci and code crushman are return too much extra content

Generate code to concatenate two strings in Javascript:

I cannot use the stop sequence as it’s not fixed how the code generation will end at the same time i do not want to limit maximum length or have to provide it for each prompt

what to do?

Would using the word function as a stop setting help

It would work if you only wanted to codex to generate one function at a time