Sign in
Log inSign up

findIndex for older browsers

andyshah's photo
andyshah
·Sep 18, 2019

Hello I have an issue with findIndex specifically with IE11. It doesn't work! Can someone help me change this to work with IE11.

var index = items.findIndex(x => x.id==id)  
    if (index != -1)
        {
        items[index].q = items[index].q+1;
        localStorage.setItem('products', JSON.stringify(catItems));
        }

I have tried this but can't figure out exactly what I need to change in order for the current item's q to increment by 1:

if (items.filter(function(e) { return e.id === id; }).length > 0) {
    //how to get the current item q and increment
    }

Any help appreciated, cheers!