I have an array of objects

```
const contentTypes = [
    {
        "contentType": {
            "content_type_id": 2,
            "content_type": "image",
        },
    },
    {
        "contentType": {
            "content_type_id": 3,
            "content_type": "video",
        },
    },
    {
        "contentType": {
            "content_type_id": 1,
            "content_type": "audio",
        },
    },
]

```

This is my function `setType`, where I find any element and set the `content_type_id` to `content_type`. I convert the value in a string

```
const setType = (selectedType) => {
    _setType(selectedType)
    const typeString = contentTypes.find((item) => {
        return item.contentType.content_type_id === selectedType
    }).contentType.content_type;
    onTypeChange(typeString)
}

```

My problem is that I also have an element in the array `contentTypes` without the `content_type_id` and `content_type` so I get this error

**Unhandled Runtime Error
TypeError: Cannot read property 'contentType' of undefined**

This is a jsFiddle => <https://jsfiddle.net/9x426Lv7/2/>

How can I skip this element in the find method? Is there a better way to do this?