Javascript implementation of Longest Common String