easiest way to implement finite state machine in javascript?

i was searching the forums and there are quite a few options when it comes to fsm, libraries, different approaches etc…a lot of data that does not help make my desicion
what to do.

first of all i use javascript, and i know that ai soon becomes too complex to handle if you do not plan it, so what path should i take? use a library like playmaker, or try to code something my own. to be honest there are no simple javascript tuts about fsm.

if somebody has experience with this share with me. thanks!

There’s an example in the Wiki unifycommunity.com

You can try to use the Design Pattern State. At the start is odd but when you understand becomes easy. Also it is good if you need to change something later.