Java Substring String Method Javascript Array