Javascript Challenges

#1 Fooling around boolean

Look at the following "implementation" of a xor method on the prototype of the Boolean type.

Boolean.prototype.xor = function ( value ) { return !!this !== !!value; };

When we execute the following statement we get an unexpected result.

false.xor(false);   // => true

Exercise

Correct!
False!

Why does xor resolves in an unexpected manner?

Exercise

Correct!
False!

Write the code to fix the implementation of xor method:

Boolean.prototype.xor = function ( value ) { return !!this !== !!value; };