I am facing a challenge with a nodelist:
const list = document.querySelectorAll('.list > a')
Each "a" tag contains a string value.
An example of the list structure is as follows:
<ul>
<a href="#"><li>Lorem Ipsum dolor</li></a>
<a href="#"><li>Sit Amet Bla bla</li></a>
<a href="#"><li>Sit Ahhh ppppp</li></a>
<a href="#"><li>Loret loops stuff</li></a>
<a href="#"><li>....</li></a>
<a href="#"><li>...</li></a>
<a href="#"><li>.... and so on</li></a>
</ul>
My goal is to remove duplicates based on the first 5 characters of each string. For instance, if two strings start with the same 5 characters, I need to keep only one of them.
Each time I encounter a new element, I must compare it with existing elements in the list and remove any duplicates with the same initial 5 characters.
I hope this explanation clarifies the situation.