Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q7 of 15
PowerShell - Variables and Data Types
Find the error in this code snippet:
$hash = @{ 'Key1' = 'Value1', 'Key2' = 'Value2' }
AValues cannot be strings
BKeys must be integers, not strings
CMissing @ symbol before braces
DUse semicolons instead of commas between pairs
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct hash table syntax

    Pairs inside @{} must be separated by semicolons, not commas.
  2. Step 2: Identify the error in the code

    The code uses commas between pairs, which causes a syntax error.
  3. Final Answer:

    Use semicolons instead of commas between pairs -> Option D
  4. Quick Check:

    Separate key-value pairs with semicolons in hash tables [OK]
Quick Trick: Separate pairs with semicolons, not commas [OK]
Common Mistakes:
  • Using commas instead of semicolons
  • Omitting @ symbol
  • Using wrong key types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes