$first + $second joins "Good" and "Morning" without space, resulting in "GoodMorning".
Step 2: Identify missing space
To separate words, a space string ' ' should be added between variables.
Final Answer:
Missing space between words in concatenation -> Option B
Quick Check:
Concatenation lacks space, so words join directly [OK]
Hint: Add ' ' between strings to include spaces [OK]
Common Mistakes:
Assuming + adds space automatically
Thinking variables are undeclared
Believing Write-Output is wrong
5. You want to create a full name string from variables $firstName and $lastName with a space in between. Which of these PowerShell commands correctly does this and outputs the full name?
hard
A. Write-Output $firstName * ' ' * $lastName
B. Write-Output $firstName + $lastName
C. Write-Output $firstName - $lastName
D. Write-Output "$firstName $lastName"
Solution
Step 1: Understand string interpolation in double quotes
Using double quotes with variables inside inserts their values with spaces as typed.
Step 2: Compare options
Write-Output "$firstName $lastName" uses double quotes with space between variables, producing correct full name with space.
Final Answer:
Write-Output "$firstName $lastName" -> Option D
Quick Check:
Double quotes allow variable insertion with spaces easily [OK]
Hint: Use double quotes to insert variables with spaces easily [OK]
Common Mistakes:
Forgetting space in concatenation
Using - or * operators incorrectly
Not using double quotes for interpolation
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.