I don't understand why my function is not giving similar output as the first example of powershell code

PS C:\Users\shane> $x = 3
PS C:\Users\shane> $y = 6
PS C:\Users\shane> $a = $x + $y
PS C:\Users\shane> Write-Host "The answer is $a"
The answer is 9

My function using similar logic

PS C:\Users\shane> Function Add ($x, $y){
>> $a = $x + $y
>> Write-Host “The Answer is $a”
>> }
>>
PS C:\Users\shane> add 3,6
The Answer is 3 6

I would expect the output to say "The Answer is 9" instead of "The Answer is 3 6"

What am I doing wrong?

I see what I was doing wrong. I was calling the function with a comma between the arguments
add 3,6 #incorrect
it should have been
add 3 6 #correct

I need to really brush up on the basics :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.