# How to efficiently come to a result with XOR?

Hi, i am following a JS course. One of the exercices is this:

Write a function `xor` that takes two Boolean values. If both values are different, the result should be `true` . If both values are the same, the result should be `false`.

I have learned about OR-AND-NOT so i tried to figure out how to combine those.
After 2 hours making different combinations i still had no solution so i googled it up.
Now i understand how the xor function works but i do not understand how to come to the solution without the google help.
Could someone explain to me how to come to a solution in a logical way, rather than trying all possible combinations untill i get lucky?

Thanks for the help.

Welcome to FCC @oliebaron . It is important to post your solution here to get the answer you seek.

Just use XOR operation (^)

Otherwise, you go like:

return bool1 !== bool2

Thanks for the reactions.
I will rephrase a bit:
The problem is i don not know how to come to solution XOR=
(x || y) && !(x && y).
As i learned NOT,AND and OR, i tried to combine those to come to the solution.
I tried (x || y)! , (x && y)! , (!x || y), and many more. After 2 hours searching i still had no answer. It looked like trying solving the exercise this way was almost impossible. So how could i solve the puzzle without cheating on google?