Bird
0
0

Identify the error in this PowerShell code:

medium📝 Debug Q6 of 15
PowerShell - Operators
Identify the error in this PowerShell code:
if $x -eq 10 { 'Match' }
ACurly braces should be parentheses
BWrong operator used
CMissing quotes around 10
DMissing parentheses around condition
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for if statement

    PowerShell requires parentheses around the condition in if statements.
  2. Step 2: Identify the missing element

    The code lacks parentheses around '$x -eq 10', causing a syntax error.
  3. Final Answer:

    Missing parentheses around condition -> Option D
  4. Quick Check:

    Use parentheses for conditions in if [OK]
Quick Trick: Always put condition inside parentheses in if [OK]
Common Mistakes:
  • Omitting parentheses
  • Using wrong operator
  • Misplacing braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes