I have an array of userid and I want to map through them and get the index of a single userid that matches. How do I do that?
const userid = [ "user1", "user2", "user3" ]
userid.map((user,index) => {
if(user === "user2") return index
}
Expecting output
[1]
Actual Output
[undefined,1,undefined]