Bird
0
0

Identify the error in this PowerShell function:

medium📝 Debug Q6 of 15
PowerShell - Functions
Identify the error in this PowerShell function:
function Get-Value {
  return
  10
}
AFunction outputs both null and 10
BSyntax error: return must be followed by a value
CReturn statement without a value returns null, so 10 is ignored
DFunction returns 10 correctly
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the return statement usage

    Return without a value returns null and exits the function immediately.
  2. Step 2: Understand code after return

    The 10 after return is never executed or output because return exits function.
  3. Final Answer:

    Return statement without a value returns null, so 10 is ignored -> Option C
  4. Quick Check:

    Return without value = null output [OK]
Quick Trick: Return without value outputs null and exits [OK]
Common Mistakes:
  • Expecting return without value to output next line
  • Thinking return without value causes syntax error
  • Assuming function outputs 10 after return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes