PowerShell - String OperationsWhich of the following is the correct syntax to concatenate the strings stored in $str1 and $str2 with a space in between?A$str1 / ' ' / $str2B$str1 -join ' ' -join $str2C$str1 * ' ' * $str2D$str1 + ' ' + $str2Check Answer
Step-by-Step SolutionSolution:Step 1: Identify the correct operator for string concatenationThe + operator joins strings; to add a space, include ' ' between them.Step 2: Construct the expression$str1 + ' ' + $str2 correctly concatenates with a space.Final Answer:$str1 + ' ' + $str2 -> Option DQuick Check:Concatenate with + and spaces as strings [OK]Quick Trick: Use + with ' ' to add spaces between strings [OK]Common Mistakes:Using -join incorrectly for stringsUsing arithmetic operators like * or /Forgetting to add space as a string
Master "String Operations" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Cmdlets and Pipeline - Get-Member for object inspection - Quiz 7medium Cmdlets and Pipeline - Pipeline concept (|) - Quiz 4medium Cmdlets and Pipeline - Why cmdlets are the building blocks - Quiz 9hard Control Flow - Why control flow directs execution - Quiz 3easy Operators - Range operator (..) - Quiz 2easy String Operations - Select-String for searching - Quiz 4medium Variables and Data Types - Integer and floating-point types - Quiz 8hard Variables and Data Types - Boolean values - Quiz 1easy Variables and Data Types - Boolean values - Quiz 10hard Variables and Data Types - Why variables store data - Quiz 10hard