Diff Two Arrays I have a question

Tell us what’s happening:
I finished the exercise, but when I consulted the other way, I found a way to do the following:

Your code so far

function diffArray(arr1, arr2) {
      return arr1
            item => !arr1.includes(item) || !arr2.includes(item)

    diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

I understood the above code but there was one section that I wondered:

item => !arr1.includes(item) || !arr2.includes(item) 

This function returns !arr1.includes(item) || !arr2.includes(item) So “!” before arr1.includes(item) and arr2.includes(item) what role does it have?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/78.0.136 Chrome/72.0.3626.136 Safari/537.36.

Link to the challenge:

The ! gives the opposite Boolean value.

!false means true and viceversa

You can also use it with truthy and falsy values
!undefined is true, and !!undefined is false

1 Like