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 trialMartin Park
12,792 PointsHelp with Students GPA Challenge?
Hi,
I can't seem to pass this PHP challenge. I'm sure I'm doing something wrong but I can't see it? Anyone able to help please?
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
if ($studentOneGPA == 4.0) {
echo "$studentOneName has made the Honor Roll";
} else {
echo "$studentOneName has a GPA of $studentOneGPA";
}
if ($studentTwoGPA == 4.0) {
echo "$studentTwoName has made the Honor Roll";
} else {
echo "$studentTwoName has a GPA of $studentTwoGPA";
}
?>
1 Answer
Corey Cramer
9,453 PointsYou have an extra word in your echo statement, aside from that 100% valid.
echo "$studentOneName has made the Honor Roll";
should be:
echo "$studentOneName made the Honor Roll";
Martin Park
12,792 PointsMartin Park
12,792 PointsOh my gosh! I'm so embarrassed! Thank you, was staring at that for ages. That'll teach me not to read things properly.
Corey Cramer
9,453 PointsCorey Cramer
9,453 PointsI can't tell you how many hours I have spent looking at errors in my code where I typed one thing and subconsciously inserted something extra. Seems silly but the trick is to read everything out loud including punctuation e.g "Echo double-quote dollar sign student one name has made the honor roll double-quote semicolon".
Semicolons are important because the error it produces won't be for the line that is missing it.
Martin Park
12,792 PointsMartin Park
12,792 PointsThanks for the suggestion Corey. I'll certainly try that reading out loud tip :)