Truthiness Normalizer
MediumAcc. 78.4%
+40 XP 15
Binary Normalization
When communicating with low-level systems (like shaders or bitmasks), you often need to convert "Truthiness" into a strict binary integer: 1 for everything truthy, and 0 for everything falsy.
The Assignment
Your function receives a parameter val.
- If
valis truthy, return the number1. - If
valis falsy, return the number0. - Requirement: Perform this conversion in a single line of code using only unary and logical operators.
01EXAMPLE 1
Input
val = "Active"Output
1Explanation: "Active" is truthy.
Constraints
- Return a number (1 or 0).
- One-line implementation preferred.
CoercionLogicProfessional
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
val"Hi"
Expected Output
1
Click RUN to test your solution