I have a function that I'm trying to check if a value exists already. However even though values exist it's still returning -1. I'm trying to get my if/else statement working that if an item exists it "alerts" and if doesn't it runs the function addItem();

```
$(".detail-view button").on("click", function () {
    itemExists();

    function itemExists() {
        var detailID = $(this).attr('id');
        var itemArr = [];
        $("input#lunchorder_item_entry_id").each(function (index) {
            var lunchItemID = $(this).val();

            itemArr.push(lunchItemID);
        });

        addItem();

        alert(jQuery.inArray(detailID, itemArr));

        /*
        if (jQuery.inArray(detailID, itemArr)) {
            alert("You have already added this item. If you want to change item details, please remove the item and re-add it to your cart. Thank You!");
        } else {
            // the element is not in the array
            addItem();
        } */

        console.log(itemArr);
    }

```