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 trialYele X.
5,537 PointsChange the value in the flavor variable to cookie dough. Preview the code and make sure the message appears. Task 4 of 4
This challenge asks to change the value of the $flavor variable to "cookiedough". Once I do this, though, without making any other changes, it fails.
What am I missing?
<?php
$flavor = "marionberrypie";
echo "<p>Your favorite flavor of ice cream is ";
echo "$flavor";
echo ".</p>";
if ($flavor == "cookiedough") {
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
} else {
}
?>
3 Answers
James Best
11,112 PointsHey,
If you are submitting the code above the reason it is failing is that you have to assign cookiedough to the variable flavor. It is currently marionberrypie and so the if statement is failing and so I assume the quiz is failing.
Does that make sense?
Hope that helps
James
Joe Mills
18,617 PointsAs James said the reason that code won't work is because the flavor variable is still set to marionberrypie so your if statement is reading false. You need to change the $flavor variable and make sure it's spelt the same in the variable as it is in the if statement like so:
$flavor = "cookie dough";
if ($flavor == "cookie dough") {
Yele X.
5,537 Pointsyes, i already said in my question "even after I change it, it still fails". I may have refreshed the page and the screenshot is from before I change the variable value. Even after I do, the challenge still fails.
James Best
11,112 PointsOk so I went back and did the quiz again and the mistake in your code is so small it is easy to miss. The variable should be 'cookie dough' not 'cookiedough'. You are missing a space between the words and so the test is failing.
Hope that helps.
James
Yele X.
5,537 PointsYele X.
5,537 Pointsyes, i already said in my question "even after I change it, it still fails". I may have refreshed the page and the screenshot is from before I change the variable value. Even after I do, the challenge still fails.