lundi 15 avril 2019

If-statement not working, from a noob that would appreciate some help :)

I am trying to clense a dataset, but my if statement appears not to work.

The first part: x.sites.length>0 seems to work by itself. The second part: (x !== undefined) doesn't seem to register at all. In my return Array, some of the undefineds are still there. I have tried various different way of writing (x !== undefined), but none of them seem to work for me.

Any thoughts?


export function clenseData(dataset){    


    let cleansedSet = dataset.map(x=>{

        if(x.sites.length>0 && (x !== undefined))
        {return x;}//doesn't work.
    })
    console.log(cleansedSet);
    debugger;
    return cleansedSet;
}


Aucun commentaire:

Enregistrer un commentaire