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 trialRandy Crowson
2,531 PointsModify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.
Been working on this and getting tons of wrong answers and am very frustrated. What should this answer be. I am going to cancel my membership with teamtreehouse if someone doesn't answer me with code that 100% works. I have had enough now going 4 hours on one stupid challenge.
<?php $flavor ="vanilla"; echo "<p>Your favorite flavor of ice cream is "; echo "vanilla"; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
35 Answers
HELGA TANWANI
2,059 Pointschallenge 2 asked:
Modify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.
I had the following which worked for me:
<?php $flavor = "mint";
echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
Randy Crowson
2,531 PointsThanks for trying. I will try to find someone in this company that can fix this if not I'm not wasting any more time with this. Thanks again.
Paul Franz
4,461 PointsI think you're kind of overreacting. There have been times a code challenge hasn't parsed for me because of some tricky text, but usually I find out I made a mistake somewhere.
Passed this awhile ago without any problems, so I'd recommend re-reading the directions and making sure you're following them exactly.
Your attitude here is kind of a turn-off for people who may want to help you.
HELGA TANWANI
2,059 Points<?php $flavor = "mint";
echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
Randy Crowson
2,531 PointsBummer! Be sure to update the output to include your flavor, without changing any of the other code.
Ary de Oliveira
28,298 Points<?php
echo "<p>Your favorite flavor of ice cream is "; echo "vanilla"; echo ".</p>"; echo "<p>Hal's favorite flavor is cookie dough, also!</p>"; $flavor = "tomato"; echo"Your favorite flavor of ice cream is"; echo$flavor; echo"."; if($flavor=="Mint") echo "So my favorite flavor is Tomato "; ?>
brahim
Courses Plus Student 11,605 PointsThis code works for me
<?php $flavor = "nuts";
if ($flavor = "nuts") { echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; } else { echo "<p>Hal's favorite flavor is cookie dough, also!</p>"; } ?>
Leonardo Hernandez
13,798 Points<?php
$variable = "Cookie dough";
echo "<p>Your favorite flavor of ice cream is ";
echo $variable;
echo ".</p>";
if ($variable = "cookie dough") // Evaluates to TRUE
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
If you copy and paste this and click 'check work' you will get a wrong answer,
But I have presented you with the structure! Take a break! come back in a couple of hours. You will feel better and probably pass the task.
Matthew Jones
1,643 PointsI am not able to pass this code challenge either...
i have spent around 3 to 4 hours on this. I look at all the forum posts, but they don't seem exactly accurate or relevant to me or my case???
its very disconcerting...this is not hard...all the answers given I already have in my mind and have tried them, but they all fail...can someone help?
take a look at these screen shots as they best illustrate the situation: http://screencast.com/t/ROY4HHLSbfNk you can see here I passed code challenge 3 with the correct answer. (despite no need for "quotation marks" strangely???)..even if i add the quotation marks taks 3 fails! anyway... i carry on.
but as you can see when i move to task 4 http://screencast.com/t/HrANRVbtTjot once I change the "flavor variable" to "cookie dough" i know that I am supposed to put something like "{ echo "Randy's favorite flavor is cookie dough, also!"; } ?> but i dont get why nothing I try works? you dont see any code there yet, because I have tried everything. for hours and hours. what do i do? i looked at all your posts and threads and tried so many variations. I just want to move on...
is there a way to keep carrying on with learning even if we cannot pass a code challenge? I dont believe that my not passing this code challenge reflects a true lack of capability , skill or understanding.
I want to move on! can someone help?
Alessandro Elkan
Courses Plus Student 7,447 PointsThis guy gives the worst tests
Randy Crowson
2,531 PointsHelga, I just got this one finally. Thanks for your help. Everyone else, sorry I got so frustrated and had a bad attitude. I was just kicking my butt on a bad day...lol. Thanks everyone that gave input.
Shilpa Kothari
4,518 PointsHi Randy
I also tried working on this code but I am still not getting it. can you tell what exactly you did?
Thanks Shilpa
HELGA TANWANI
2,059 Points<?php
$flavor ="vanilla"; echo "Your favorite flavor of ice cream is ". $flavor . "."; echo "Randy's favorite flavor is cookie dough, also!";
// you can also save cookie dough to a variable and then echo it as part of your string like so:
$fav_flavor = "cookie dough"; echo "Randy's favorite flavor is " . $fav_flavor . ", " . "also!";
?> // end of php script
Hope this helps let me know
Randy Crowson
2,531 PointsI get this error message:
Bummer! Be sure to update the output to include your flavor, without changing any of the other code.
Randy Crowson
2,531 PointsError message is now
Oops! It looks like Task 1 is no longer passing.
HELGA TANWANI
2,059 Points//This should work:
<?php $flavor = "mint";
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>";
?>
Randy Crowson
2,531 PointsThank you sooo much Helga. Finally it works.
HELGA TANWANI
2,059 Pointsno worries. glad to be of help.
Randy Crowson
2,531 PointsI spoke too soon. It had reset my to challenge 1 then it didn't work on challenge 2 ugh!!!
HELGA TANWANI
2,059 PointsI need to know exactly where you are stuck and what you are having problems with to help
HELGA TANWANI
2,059 Pointspaste the instructions and code you are struggling with here
Randy Crowson
2,531 PointsModify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.
I used your code:
<?php $flavor = "mint";
echo "Your favorite flavor of ice cream is "; echo $flavor; echo ".";
if($flavor=="cookie dough") echo "Randy's favorite flavor is cookie dough, also!";
?>
I get this error:
Bummer! Be sure to update the output to include your flavor, without changing any of the other code.
HELGA TANWANI
2,059 PointsThat was not my code exactly. This is my code and it worked:
<?php $flavor = "mint";
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>";
?>
Randy Crowson
2,531 PointsStill error:
Bummer! Be sure to update the output to include your flavor, without changing any of the other code.
Randy Crowson
2,531 PointsSame error: Bummer! Be sure to update the output to include your flavor, without changing any of the other code.
HELGA TANWANI
2,059 Pointsyou are on task number 2 right?
Randy Crowson
2,531 PointsYes
HELGA TANWANI
2,059 PointsThen the code I gave above should work as it works for me in my editor not sure why it does not work for you. If you can paste exactly the screenshot of what you wrote in your editor maybe I could help. But other than that, I gave you the same exact code I ran on my editor which worked for me. You may have to exit the editor and come back again into the task and try again.
Randy Crowson
2,531 Points<?php $flavor = "mint";
echo "Your favorite flavor of ice cream is "; echo $flavor; echo "."; echo "Randy's favorite flavor is cookie dough, also!";
?>
What did you put for task 1? Maybe that is where the problem is coming from.
HELGA TANWANI
2,059 Pointsfor task 1 :
<?php $flavor = "mint";
echo "<p>Your favorite flavor of ice cream is "; echo "vanilla"; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
Randy Crowson
2,531 PointsSame here. I exited out and then resumed and have the same code has you for task 1 and no problem. Code for task to keeps giving me that same error:
Same error: Bummer! Be sure to update the output to include your flavor, without changing any of the other code.
Randy Crowson
2,531 PointsCopied straight out of challenge 2:
<?php $flavor = "mint"; echo "Your favorite flavor of ice cream is "; echo $flavor; echo "."; echo "Randy's favorite flavor is cookie dough, also!";
?>
HELGA TANWANI
2,059 Pointssorry not sure how else I could help
Task 1 instructions were:
This block of code displays two sentences related to flavors of ice cream. In this code challenge, we'll modify the code block to use a variable and a conditional. First, create a new variable named flavor and assign your favorite flavor as the value. (Add this command at line 2. Don't forget to use a dollar sign in the variable name, and don't forget to end your command with a semi-colon.)
and I had the following and it worked for me:
<?php
$flavor = "mint";
echo "<p>Your favorite flavor of ice cream is "; echo "vanilla"; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
HELGA TANWANI
2,059 Pointsno worries best wishes
Will Vincent
2,594 PointsIt does not work 4 me
Vipin Singh
15,268 Points<?php
$flavor = "mint";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor; echo "";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}
?>
Vaughn Lawson
3,483 PointsVaughn Lawson
3,483 PointsHi all, this code worked for me, hope this helps. <?php $flavor = "vanilla"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
?>
Please note no "" around the echo $flavor.