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 trialvivek gupta
410 Pointsnot able to understand question
i know the concept of if else but the question I think is incomplete
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
if($studentOneGPA == 4.0) {
echo "$studentOneName made the Honor Roll";
}
else {
echo "$studentOneName has a GPA of GPA";
}
if($studentTwoGPA == 4.0) {
echo "$studentTwoName made the Honor Roll";
}
else {
echo "$studentTwoName has a GPA of GPA";
}
?>
1 Answer
Thomas Fildes
22,687 PointsHi Vivek,
The problem with the code is that you are not including the variables stored content when echoing an output in each condition. Also, you need to output the GPA value not the word GPA when it asks you to output "has a GPA of GPA" inside the else block of code. Please see the below code I used to pass this challenge:
<?php
if ($studentOneGPA == 4.0) {
echo $studentOneName . " made the Honor Roll";
} else {
echo $studentOneName . " has a GPA of " . $studentOneGPA;
}
if ($studentTwoGPA == 4.0) {
echo $studentTwoName . " made the Honor Roll";
} else {
echo $studentTwoName . " has a GPA of " . $studentOneGPA;
}
?>
As you can see above, you need to use some concatenation to link variables and strings when echoing the output.
Hope this helps! Happy Coding!!!