Halfway through javascript implementation

Javascript