So i have this array as my state:
["item-one","item-two", "item-three"] Now i have these items on my webpage:
Item One Item Two Item Three Item Four Item Five How can i filter these items based on the state of my array. So when i filter i would get the three first items? The html of the items are like so.
<div> <label htmlFor="item-one">Item One</label> <input type="checkbox" name="" id="item-one"/> </div> <div> <label htmlFor="item-two">Item Two</label> <input type="checkbox" name="" id="item-two"/> </div> <div> <label htmlFor="item-three">Item Three</label> <input type="checkbox" name="" id="item-three"/> </div> <div> <label htmlFor="item-four">Item Four</label> <input type="checkbox" name="" id="item-four"/> </div> <div> <label htmlFor="item-five">Item Five</label> <input type="checkbox" name="" id="item-five"/> </div> should i use a map function or what is the best approach?
map()ing your array to render the elements.mapthe array can be filtered usingfilter