Bird
0
0

What will this PowerShell function output?

medium📝 Command Output Q5 of 15
PowerShell - Functions
What will this PowerShell function output?
function Test-Return {
  param($x)
  if ($x -gt 10) { return "High" }
  "Low"
}
Test-Return 5
AHigh
BError
C5
DLow
Step-by-Step Solution
Solution:
  1. Step 1: Analyze condition in function

    If input is greater than 10, function returns "High"; otherwise, it outputs "Low".
  2. Step 2: Evaluate input 5

    5 is not greater than 10, so function outputs "Low".
  3. Final Answer:

    Low -> Option D
  4. Quick Check:

    Input 5 returns "Low" [OK]
Quick Trick: Return exits function early; else last line outputs [OK]
Common Mistakes:
  • Expecting 'High' for input less than 10
  • Confusing return with output
  • Syntax errors in if statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes