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 trialSP Prabhakar
11,429 Pointsif condition
Check if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the student name variable to replace NAME when displaying the following line: NAME made the Honor Roll If the students GPA is not equal to 4.0, use the student name variable to replace NAME AND the student GPA variable to replace STUDENT GPA when displaying the following line: NAME has a GPA of STUDENT GPA
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
if($studentOneGPA == 4.0){
echo $studentOneName. " made the Honor Roll";
}else if($studentTwoGPA == 4.0){
echo $studentOneName. " made the Honor Roll";
}else if($studentOneGPA !== 4.0){
echo $studentOneName. " has a GPA of ".$studentOneGPA;
}else{
echo $studentTwoName. " has a GPA of ".$studentTwoGPA;
}
//Place your code below this comment
?>
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsAs you have your code written, you're only going to get one echo depending on which condition was true.
But you need separate output for each student. So you need to break that up into separate if/else statements for each student.
SP Prabhakar
11,429 PointsSP Prabhakar
11,429 PointsThanks for your help. Dear jason, can you suggest me what is best way to practice JavaScript more and more? what is the best book and resource for learning JavaScript apart from treehouse? I want to have better command on JavaScript and Jquery. I need your valuable answer. Thanks
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsIt looks like you've already started javascript basics here on treehouse. I recommend you complete the rest of the javascript/jquery courses here on treehouse and then I think you'll be in a better position to assess where you need to go from there.
There's a javascript beginner track that you could join if you would like a guided path on the order to take certain courses.
https://teamtreehouse.com/tracks/beginner-javascript
Beyond that, I don't have any specific recommendations on beginner level javascript books. I would recommend that you search amazon and look for well reviewed books.
The "You don't know JS" series of books is available for free on github here: https://github.com/getify/You-Dont-Know-JS
If you're just starting out then I recommend you save that link for a later time. These books are not suitable for beginners in my opinion. They are for when you're ready for a deeper understanding of JavaScript.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsI just remembered this one for a more beginner friendly book: https://www.amazon.com/JavaScript-JQuery-Interactive-Front-End-Development/dp/1118531647/
I haven't gone through it personally but it's pretty well known and reviewed and might be something to look into further if you want to go the book route.
That same author also has an html/css book that you may be able to get as a set if that's something you're also interested in.
SP Prabhakar
11,429 PointsSP Prabhakar
11,429 Pointsdear jason, thanks for your valuable information. the book you have suggested is an amazing book authored by jon ducket. His html/css and javascript/jquery are both best book for beginners. i have studied all of them. I have just finished it (javascript/jquery). I would definitely study your other suggested book which is "you don't know js". Dear jason, I love coding and i wanted to be a successful programmer. Your valuable suggestions and reply would always give me strength for coding. if you don't mind, kindly be my mentor and help me to be a successful programmer. Whenever i would have any problem regarding programming, i would like to be in touch with you through treehouse community or through your email, if you can provide me. thanks once again for helping me.