First draft JS implementation

First draft JS implementation