I have an array like:
var participants = [
{username: "john", time: null},
{username: "samira", time: null},
{username: "mike", time: null},
{username: "son", time:null}
]
I want to remove an item by username:
const index = participants.map(x => {
x.map(y => {
return y.username;
})
}).indexOf(username); //get index of username
participants.splice(index, 1);
Hence, index of username returns "-1", therefore participants array becomes 0?
Expected output, by username: 'son':
[
{username: "john", time: null},
{username: "samira", time: null},
{username: "mike", time: null}
]
UPDATE:
Turns out my array is within an array, like this

array.findIndex()as well if you ever need to do more than just filter out something.