Javascript Loop Through Array With Index And Ring