Sum All Array Elements Javascript Substring Function