Javascript Remove Duplicate Objects From Array Using While Loop