Truthiness Counter
MediumAcc. 68.1%
+45 XP 15
Truthiness as a Number
In JavaScript, every value has a "truthiness." When you force a boolean into a math operation, true becomes 1 and false becomes 0.
This means you can count truthy values by simply adding their boolean forms together!
The Assignment
Your function receives three parameters: a, b, and c.
- Determine the truthiness of each value.
- Return the total count (0, 1, 2, or 3) of values that are truthy.
01EXAMPLE 1
Input
a = "Hello", b = 0, c = trueOutput
2Explanation: "Hello" is truthy (1), 0 is falsy (0), true is truthy (1). Sum = 2.
Constraints
- Return the count as a number.
- Handle inputs of any data type.
CoercionLogicMastery
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
a"Hi"
b0
ctrue
Expected Output
2
Click RUN to test your solution