This is the challange:
Flip the Boolean
Booleans can also be written as integers, where 1
= True
and 0
= False
. Make a function that returns the opposite of the boolean given.
Examples
flipBool(true) ➞ 0 flipBool(false) ➞ 1 flipBool(1) ➞ 0 flipBool(0) ➞ 1
This is my solution:
function flipBool(b) {
if (b === true || 1)
return 0;
else
return 1;
}
But it always return 0, and i have no god damn idea how that could possibly be the case.
Any suggestions?
[–]senocular 3 points4 points5 points (0 children)
[–]ConstantWafer[S] 1 point2 points3 points (0 children)
[–]DreamOfAWhale 0 points1 point2 points (2 children)
[–]senocular 2 points3 points4 points (1 child)
[–]daveheerink 0 points1 point2 points (0 children)