Bird
0
0

Identify the error in this PowerShell code:

medium📝 Debug Q6 of 15
PowerShell - Operators
Identify the error in this PowerShell code:
$nums = 1..5..1
AIt creates a range from 1 to 5 with step 1 correctly
BIt creates an array with one element: 1..5..1
CRange operator cannot have two dots twice; syntax error
DIt creates a range from 1 to 1
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the syntax of the range operator

    The range operator uses exactly two dots .. between two numbers.
  2. Step 2: Identify the error in 1..5..1

    Using two sets of dots is invalid syntax and causes an error.
  3. Final Answer:

    Range operator cannot have two dots twice; syntax error -> Option C
  4. Quick Check:

    Range operator syntax = number..number only [OK]
Quick Trick: Range operator uses exactly two dots, no more [OK]
Common Mistakes:
  • Trying to specify step size with extra dots
  • Confusing range operator with other languages' syntax
  • Expecting it to create a stepped range

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes