Check if the array of objects contains an element with a specific value. Javascript code to check if an array of objects includes an item with a value.
${selectedItems?.find( (findItem) => findItem.id === item.id ) ? 'bg-blue-100 dark:bg-blue-900' : 'bg-white-200' }
In the above example we have an array of objects. The array name is selectedItems
we are checking if it contains an item with a specific id and then if it contains change the background color of that item in the list displayed.