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.

  1. If val is truthy, return the number 1.
  2. If val is falsy, return the number 0.
  3. Requirement: Perform this conversion in a single line of code using only unary and logical operators.

01EXAMPLE 1

Inputval = "Active"
Output1

Explanation: "Active" is truthy.

Constraints

  • Return a number (1 or 0).
  • One-line implementation preferred.
CoercionLogicProfessional
JavaScript
Loading...
4 Hidden

Input Arguments

val"Hi"

Expected Output

1

Click RUN to test your solution