Bird
0
0

What does the ternary operator condition ? true-value : false-value do in PowerShell 7+?

easy📝 Conceptual Q11 of 15
PowerShell - Operators
What does the ternary operator condition ? true-value : false-value do in PowerShell 7+?
AIt comments out a line of code.
BIt chooses one of two values based on a condition.
CIt defines a function with two parameters.
DIt creates a loop that runs twice.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the ternary operator structure

    The ternary operator uses a condition followed by a question mark, then a value if true, a colon, and a value if false.
  2. Step 2: Identify its purpose

    It evaluates the condition and returns the true-value if the condition is true, otherwise the false-value.
  3. Final Answer:

    It chooses one of two values based on a condition. -> Option B
  4. Quick Check:

    Ternary operator = choose value based on condition [OK]
Quick Trick: Think: condition ? yes : no picks one value fast [OK]
Common Mistakes:
  • Confusing ternary with loops
  • Thinking it defines functions
  • Assuming it comments code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes