PowerShell - OperatorsFind the problem in this PowerShell snippet:$range = 5..3$range += 2AThe range 5..3 is invalidBAdding 2 to an array causes an errorCRange operator cannot be assigned to a variableDThe += operator appends 2 to the array, no errorCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand the range 5..3This creates an array: 5, 4, 3.Step 2: Analyze the += operationAdding 2 with += appends 2 to the array, resulting in 5, 4, 3, 2.Final Answer:The += operator appends 2 to the array, no error -> Option DQuick Check:+= appends elements to arrays in PowerShell [OK]Quick Trick: += adds elements to arrays, no error [OK]Common Mistakes:Expecting += to add numbers arithmetically to arraysThinking range operator output is immutableAssuming 5..3 is invalid
Master "Operators" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Control Flow - Why control flow directs execution - Quiz 2easy Control Flow - Why control flow directs execution - Quiz 13medium Operators - Assignment operators - Quiz 2easy Operators - Ternary operator (PowerShell 7+) - Quiz 12easy Operators - Ternary operator (PowerShell 7+) - Quiz 11easy Operators - Why operators perform comparisons and logic - Quiz 15hard Operators - Ternary operator (PowerShell 7+) - Quiz 6medium String Operations - Why string manipulation is frequent - Quiz 3easy Variables and Data Types - Automatic variables ($_, $PSVersionTable) - Quiz 4medium Variables and Data Types - Automatic variables ($_, $PSVersionTable) - Quiz 11easy