Hi,
You do not write JavaScript code in workflow. You can use workflow steps to achieve what you can do using OOTB workflow steps. If there are tasks you wish to perform and OOTB workflow engine does not provide capability for the same,
you can write custom workflow activity for the same. Here is few articles which explains how to write the same:
http://msdn.microsoft.com/en-us/library/gg328515.aspx
https://www.youtube.com/watch?v=P0rfy8Jp2dk
Hope this helps.
-----------------------------------------------------------------------
Minal Dahiya
blog : http://minaldahiya.blogspot.com.au/