In JavaScript, the double exclamation mark (!!
) is used to convert a value to a boolean (true
or false
).
The first !
(negation) converts the value to its boolean opposite:
false
true
The second !
negates the result again:
false
→ true
true
→ false
!!
?true
or false
.
In this case, !!userInput
ensures that the condition is evaluated as a boolean (true
or false
).