Array Unique Javascript Foreach With Index