Question: this is my search handler and iam only able to get results for the last one

```
handleSearch = (event) => {
const searchWord = event.target.value;
const newFilter = this.state.data.filter((value) => {
  return (
    value.programName.toLowerCase().includes(searchWord.toLowerCase()),//not working
    value.endTime.toLowerCase().includes(searchWord.toLowerCase()),//not working
    value.description.toLowerCase().includes(searchWord.toLowerCase()) //only getting search related to this line
  )
});
this.setState({
  data1: newFilter,
});

```

};

Answer: 
You could use [Set](https://ruby-doc.org/stdlib-3.0.2/libdoc/set/rdoc/Set.html#method-i-intersection), if I get the answer properly, and check if the first hash is included in the second:

```
require 'set'

def is_included?(hash_a, hash_b)
  return hash_a.size == (hash_a.to_set & hash_b.to_set).size
end

```

So, you can check this way:

```
hash1 = {'a' => 1, 'b' => 2}
hash2 = {'a' => 1, 'b' => 2, 'd' => 3}
hash3 = {'a' => 1, 'b' => 2, 'c' => 4, 'd' => 3}
hash4 = {'c' => 4, 'd' => 3, 'e' => 5}

is_included?(hash1, hash2) #=> true
is_included?(hash1, hash3) #=> true
is_included?(hash1, hash4) #=> false
is_included?(hash2, hash3) #=> true

```

---

Also just `return hash_a.to_set <= hash_b.to_set` should work.
Edit: this solution is not working for some cases not mentioned in the original question, so this answer should fit better: <https://stackoverflow.com/a/69280216/299774>

This formula will give you what you want (for the provided examples)

```
def compare(first, second)
  ((first.to_a & second.to_a) <=> first.to_a) >= 0
end

```

How does it work?

It transforms hashes into array of key-value pairs (also arrays)

```
> hash1.to_a
=> [["a", 1], ["b", 2]]

```

So now you can do neat things, treat arrays as sets and find their intersections (the common elements):

```
> hash1.to_a & hash2.to_a
=> [["a", 1], ["b", 2]]
> hash1.to_a & hash4.to_a
=> []

```

What is left, is to check if the intersection is included in one of those arrays, the rocket method `<=>` is very useful, will give you 0 when arrays are identical, 1 if the right one is included in the left one, and -1 otherwise. You seem to be interested in the first two cases, hence `>= 0`