Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Alex Bauer
9,426 PointsCan someone help me with a public function please?
The error that I received tells me that I need to return an array.
These are the instructions: Return an collection array of house objects whose public properties roof_color OR wall_color match the passed color parameter.
Note: The local houses array contains an array of House objects, each of which has a public property for "roof_color" and "wall_color".
<?php
// add code below this comment
class Subdivision
{
public $houses;
public function filterHouseColor($color)
{
$house = array();
if ($this->houses["roof_color"] == $color OR $this->houses["wall_color"] == $color) {
$house[] = $color;
return $house;
}
}
}
?>

jamesjones21
9,260 PointsI believe you need to declare the keys inside the array for them to be noticed inside the foreach loop. As the conditions set will bring back nothing as it can't compare anything with a blank array.
1 Answer

Patrick Marshall
13,508 Points$houses is an array. You need a foreach loop to check each house in the array.

Alex Bauer
9,426 PointsOh okay ty so much for your help!
Alex Bauer
9,426 PointsAlex Bauer
9,426 PointsI used the logical operator OR because it seemed like the instruction emphasized on it.