If we can promise each element in criticalValue array is unique, we should use array.find() to check the duplicate. It stops when we find a duplicate, otherwise it finds all items.

FYI:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find