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.

  1. Determine the truthiness of each value.
  2. Return the total count (0, 1, 2, or 3) of values that are truthy.

01EXAMPLE 1

Inputa = "Hello", b = 0, c = true
Output2

Explanation: "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
JavaScript
Loading...
3 Hidden

Input Arguments

a"Hi"
b0
ctrue

Expected Output

2

Click RUN to test your solution