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 trialLouise Thomsson Erixon
1,565 PointsIf else
Hi I really need help! I have trouble in understanding this assignment so my code is very weird. But can someone please help me and explain what I am meant to do here
This is my code: <?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;
$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;
//Place your code below this comment if ($studentOneName > 4.0) { echo 'Dave has a GPA of 4.0';
} elseif ($studentTwoName < 3.8) { echo 'Treasure has a GPA of 3.8'; {
} else { echo 'Student has a GPA'; ?>
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
if ($studentOneName > 4.0) {
echo 'Dave has a GPA of 4.0';
} elseif ($studentTwoName < 3.8) {
echo 'Treasure has a GPA of 3.8'; {
} else {
echo 'Student has a GPA';
?>
1 Answer
Louise Thomsson Erixon
1,565 PointsThank you for youre answer I missed the end tag.
Teacher Russell
16,873 PointsIt's a good habit to always open and close your tags before you put anything in them. It's a simple mistake everyone makes. It's easier to see when it's someone else's code:) Do you see the problems with the conditional? Just re-watch the videos a few times to take it all in. Play with the code in Workspaces. Have fun!
Teacher Russell
16,873 PointsTeacher Russell
16,873 PointsOne thing, you're comparing the $studentName with the GPA, instead of the $studentGPA. Look closely at your comparison. One more thing. Something's missing at the very end of your conditional. A closing bracket:)