An algorithm is an algorithm. The algorithm you have coded checks if the input variable bool can be coerced into either true or false, and everything in Javascript when coerced into a boolean value will either be true or false. There are no other options.
It is working as you coded it. == and === are very different in JavaScript.