JS code is fine in chunks, and putting it there can be nice while working on it.
If the JS is in a chunk, you can just put a chunk tag on the page to include it:
Be sure it includes the script tags.
Once it's working, I usually move it to a file (so it doesn't clutter up "view source") and inject it with $modx->regClientStartupScript() or $modx->regClientScript(). In that case, make sure the file does *not* have the script tags.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html