deleting an object from an array on a click of a button

The second part of your deleteItem function’s body seems useless. While there are couple of ways to resolve it, I suggest the following:

function deleteItem(e) {
    var ul = document.getElementById('list');

    var foundIndex = tweets.findIndex(function (tweet) {
        return == id;
    if (foundIndex > -1) {
        tweets.splice(foundIndex, 1);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top