PowerShell - OperatorsWhich of the following is the correct syntax for the ternary operator in PowerShell 7+?Acondition ? true-value : false-valueBif (condition) { true-value } else { false-value }Ccondition ? true-value, false-valueDcondition : true-value ? false-valueCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall the ternary operator syntaxThe ternary operator uses the format: condition ? true-value : false-value.Step 2: Compare options'if (condition) { true-value } else { false-value }' is an if-else statement, not ternary. 'condition ? true-value, false-value' uses comma instead of colon. 'condition : true-value ? false-value' has question mark and colon swapped. Only 'condition ? true-value : false-value' matches exactly.Final Answer:condition ? true-value : false-value -> Option AQuick Check:Correct ternary syntax = condition ? true : false [OK]Quick Trick: Look for question mark then colon in correct order [OK]Common Mistakes:Using commas instead of colonSwapping question mark and colonUsing if-else instead of ternary
Master "Operators" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Cmdlets and Pipeline - Verb-Noun naming convention - Quiz 1easy Cmdlets and Pipeline - Pipeline object flow - Quiz 9hard Cmdlets and Pipeline - Pipeline object flow - Quiz 8hard Cmdlets and Pipeline - Select-Object for properties - Quiz 11easy Operators - Logical operators (-and, -or, -not) - Quiz 10hard Operators - Range operator (..) - Quiz 3easy Operators - Range operator (..) - Quiz 14medium PowerShell Basics and Environment - PowerShell versions (5.1 vs 7+) - Quiz 8hard Variables and Data Types - Automatic variables ($_, $PSVersionTable) - Quiz 10hard Variables and Data Types - Hash tables (dictionaries) - Quiz 14medium