You can type the code in an note, and then have Templater replace it using the “replace templates” command. However, if you want to execute javascript, you need to use an asterisk in the command opening:
<%* your code %>
In this case (execution commands), you also have to explicitly return the template results using tR = your output, or by defining varibles, and putting them in an interpolation command: