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 trialJohn Vicencio
6,413 PointsCheck if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the students name variable .... Issue
Source: Question: Check if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the students name variable to display "NAME made the Honor Role". If not, use the variable to display "NAME has a GPA of GPA".
Issue: per the instruction there to "check each student for GPA 4.0" if this, then that. But there are two students. So there are two if/else statements on each.
My solution didn't work, help:
if($studentOneGPA == 4.0){
echo "$studentOneName is made the Honor Role";
} else {
echo "$studentOneName is made the Honor Role";
}
if($studentTwoGPA == 4.0){
echo "$studentTwoName is made the Honor Role";
} else {
echo "$studentTwoName has a GPA of $studentTwoGPA";
}
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
?>
2 Answers
Andrew Phythian
19,747 PointsWould love more of an explanation about what you mean by "else statements on their own lines" given that in the first code block it appears to me that they are. Also seems a nit picky thing to fail the challenge over when it produces the correct output regardless.
John Vicencio
6,413 PointsI got it thanks!
Steve Berrill
20,016 Pointsyeh i also thought that was nit picking because in the video the demonstation was to use the $variable names in double quotation marks along with the text to output so i assumed it was ok to use this method instead of concatenating the variables with string.
A X
12,842 PointsAndrew Phythian : Andrew I completely agree with you about the challenge failing over how we come to the exact same output. I've noticed that happens quite frequently with the TH challenge checker. It'll want one specific result and if you don't give it, it'll "fail" you.
robert tanner
6,085 PointsTry spelling things inside a string correctly.
John Lukacs
26,806 PointsJohn Lukacs
26,806 PointsThis challenge makes you wirte the else statements on there own lines to work