I want to fill the array with gussed correct letters from the solution $Solution but everytime comes the error
"Index was outside the bounds of the array"
($arrayOutput).length=$LengthSolution doesnt work
$Solution="Apfelpfannekuchen"
$arraySolution = $Solution.ToCharArray()
$LengthSolution=($Solution|measure-object -Character).Characters
$arrayOutput@()a
while ($Input -notmatch $ Solution) {
[string]$Input = Read-Host "choose a letter"
$arrayInput = $ Input.ToCharArray()
for ($i = 0; $i -lt $LengthSolution; $i++) {
if($Input -eq $arraySolution[$i]){$arrayOutput[$i]=$Input}
else {}
}
$arrayOutput
}
$LengthSolution doesnt work
is not a valid expression, neither is$arrayOutput@()a
)$Input
as self-defined variable name because it is an automatic variableAt /tmp/home/.code.tio.ps1:7 char:13 + $arrayOutput@()a + ~~ Unexpected token '@(' in expression or statement.