Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCloud Edwards
8,132 PointsThe challenge is buggy, No 4 wont let me change the variable, it causes No 3 to fail.
When I change the $flavor var to "cookie dough" it says the Challenge 3 is no longer passing. Because the variable has been changed to match the conditional, so now the text is displayed in task 3, but not in task 4. They are mutually exclusive.
<?php
$flavor = 'd';
//$flavor = 'cookie dough';
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
echo "<p>Randy's favorite flavor is cookie dough, also $flavor!</p>";
}
?>
2 Answers
Stone Preston
42,016 Pointsyou added $flavor to the paragraph in the if statement
"<p>Randy's favorite flavor is cookie dough, also $flavor!</p>"
the challenge did not ask you to do that.
it should be:
<p>Randy's favorite flavor is cookie dough, also!</p>
full code below:
<?php
$flavor = 'cookie dough';
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}
?>
Cloud Edwards
8,132 PointsThanks, I just figured it out. My bad. Super quick response time I'm impressed, and the task isn't buggy, just the parsing is a little unforgiving.
Stone Preston
42,016 Pointsmost of the challenges require you to follow the directions very closely. if you add something it is not expecting then it probably wont let you pass. It can be pretty annoying sometimes. just remember that if it doesnt ask for it, dont add it.