I am getting different results when running the code on my computer and running it in the Exercism editor. On my pc, I get the correct output, in the editor, I get more plants than the code should output. Here is the relevant PowerShell code.
[string[]]GetPlants ([string]$student) {
$studentIndex = [Array]::IndexOf($this.students, $student)
$startIndex = $studentIndex * 2
for ($i = $startIndex; $i -lt $startIndex + 2; $i++) {
$temp = $this.plants[0][$i]
$plant = $this.plantNames[$("$temp")]
$this.studentPlants += $plant
}
for ($i = $startIndex; $i -lt $startIndex + 2; $i++) {
$temp = $this.plants[1][$i]
$plant = $this.plantNames[$("$temp")]
$this.studentPlants += $plant
}
return $this.studentPlants
}
This is the error I get .
Message: Expected exactly @(‘Clover’, ‘Grass’, ‘Clover’, ‘Clover’), but got @(‘Violets’, ‘Radishes’, ‘Violets’, ‘Radishes’, ‘Clover’, ‘Grass’, ‘Clover’, ‘Clover’).
Thanks for any feedback,
Frank