Javascript Loop Through Array With Index And Table Of Contents