PowerShell - OperatorsFind the error in this PowerShell snippet:$a = 5$a -=3Write-Output $aAThere is no error; code runs fineBThe subtraction assignment operator is split incorrectly across linesCWrite-Output requires a semicolonDVariable $a is not assigned a valueCheck Answer
Step-by-Step SolutionSolution:Step 1: Analyze operator usageThe operator -= must be on the same line as the variable and value; splitting it causes syntax error.Step 2: Confirm other syntax parts$a is assigned 5, Write-Output works without semicolon, so no error there.Final Answer:The subtraction assignment operator is split incorrectly across lines -> Option BQuick Check:Keep assignment operators and values on the same line [OK]Quick Trick: Keep operator and value on same line [OK]Common Mistakes:Splitting operator and value across linesAdding unnecessary semicolonsMisunderstanding Write-Output syntax
Master "Operators" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Cmdlets and Pipeline - Verb-Noun naming convention - Quiz 3easy Operators - Comparison operators (-eq, -ne, -gt, -lt) - Quiz 1easy Operators - Why operators perform comparisons and logic - Quiz 12easy Operators - Comparison operators (-eq, -ne, -gt, -lt) - Quiz 7medium PowerShell Basics and Environment - Command discovery (Get-Command) - Quiz 2easy PowerShell Basics and Environment - VS Code with PowerShell extension - Quiz 13medium PowerShell Basics and Environment - Why PowerShell exists - Quiz 8hard String Operations - Here-strings for multiline - Quiz 11easy String Operations - Regular expressions with -match - Quiz 7medium Variables and Data Types - Why variables store data - Quiz 7medium