Bird
0
0

Find the issue in this PowerShell snippet:

medium📝 Debug Q7 of 15
PowerShell - String Operations
Find the issue in this PowerShell snippet:
$item = "Book"
$text = "Item: $items"
Write-Output $text
AWrite-Output cannot print variables inside strings.
BMissing double quotes around string.
CVariable name typo: $items instead of $item causes empty output.
DNo issue; code runs correctly.
Step-by-Step Solution
Solution:
  1. Step 1: Compare variable names

    Variable defined is $item but string uses $items (extra 's').
  2. Step 2: Effect of typo

    $items is undefined, so replaced with empty string in output.
  3. Final Answer:

    Variable name typo: $items instead of $item causes empty output. -> Option C
  4. Quick Check:

    Variable name must match exactly for interpolation [OK]
Quick Trick: Check variable names carefully for typos in strings [OK]
Common Mistakes:
  • Typos in variable names inside strings
  • Assuming undefined variables cause errors
  • Ignoring case sensitivity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes