My javascript code like this :
<script type="text/javascript">
var clubs = [
{id: 1, name : 'chelsea'},
{id: 2, name : 'city'},
{id: 3, name : 'liverpool'}
];
if(clubs.indexOf(2) != -1)
clubs.splice(2, 1)
console.log(clubs)
</script>
For example, I want to delete the index with id = 2
I try like that, but it does not work. The index with id = 2 is not deleted
How can I solve this problem?