Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

IF ELSE statement does not properly function

$
0
0

Im trying to get this bit of code to work

$userResponse = "Y" $players = @() while ($userResponse -eq "Y") { $playerID = Read-Host "Enter Player ID" $players += $playerID $userResponse = Read-Host "Enter Another? [Y/N]" } if ($players -ge 2) { pause } else { Write-Host "Not enough players" break } $players 

But if I type in one name, for example Michael, and then type N, it doesnt break, it just lists $players. I want to make sure that unless two or more players are indicated, the program terminates.

submitted by /u/chy_vak
[link] [comments]

The post IF ELSE statement does not properly function appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles