The Gilded Entrance
EasyAcc. 96.2%
+20 XP 8
Logic in a Single Line
The Ternary Operator (? :) is a powerful shorthand. It allows you to make a decision and assign a value to a variable all in one line. It follows the pattern: condition ? value_if_true : value_if_false.
The Assignment
Your function receives a boolean parameter named isVip.
- Declare a variable named
status. - Use a ternary operator to assign
"Gold"tostatusifisVipis true, or"Silver"if false. - Return the exact string: "status : [value]" (where [value] is your
statusvariable).
01EXAMPLE 1
Input
isVip = trueOutput
"status : Gold"Explanation: isVip is true, so "Gold" is chosen.
02EXAMPLE 2
Input
isVip = falseOutput
"status : Silver"Explanation: isVip is false, so "Silver" is chosen.
Constraints
- Use the ternary operator (? :).
- The return message must match the "status : [value]" pattern exactly.
Control FlowConditionalsOperators
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
isViptrue
Expected Output
status : Gold
Click RUN to test your solution