Im using react and have an array of objects. I have created a <select> and want to add the names from the arrays as an <option> but each name is in more than 1 element, and I want them to only be added once as an <option>
<select id='sel' value={picked} onChange={x=>setPicked(x.target.value)}>
<option disabled selected>Select a student</option>
</select>
function addsss(){
if(x=>!sel.includes(x.studentName))
{
allStudentData.forEach(x=>{
sel.innerHTML += '<option value="' + x.studentName+ '">' + x.studentName + "<option/>"
}) ;
}
}```
This adds the more than once
(I have tried other things that didnt work either so im asking for help)