Verifying a record is not returned within an array

Hi folks, I’m new to this but looking a bit of help/direction in trying to write a test that verifies an ID is not returned within an array when doing a GET.
Only records that are released are returned but I need to verify that a non released record (e.g. id=789 released=false) is not present in the array returned from the response.

“id”: 123,
“released”: true,
“id”: 456,
“released”: true,

You can use the JavaScript find function.

You can simply search for the value and assert that the value is undefined (that the search doesn’t find anything).

The following example has an array of test data. The first two elements should fail as they do exist in the response. The third element should pass as it doesn’t exist.

I’m looping through the test data to prove that is does fail if the element exists. That you aren’t seeing a false positive.

const response = pm.response.json();

let testData = [123, 456, 789];

testData.forEach(id => {
    pm.test(`ID ${id} should not exist in response `, () => {
        let search = response.find(obj => {return === id})
        // console.log(search);

Thanks - that helped - got it resolved now