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 trialella ukpo
369 PointsFinal Quiz
$a = 1;
if ($a > 1) {
$a--;
$a += 2;
} elseif ($a < 1) {
$a++;
} else {
$a += 5;
}
$a = $a + 2;
echo $a;
1 Answer
Steven Parker
231,248 PointsTry writing the entire thing on a piece of paper (using separate lines as in the original), and then, one step at a time, write down what value $a would have after that step. Skip any step that would not run because of a conditional (if/elseif/else) test. Then when you get to the last line, you should have the correct answer.
Rich Donnellan
Treehouse Moderator 27,696 PointsRich Donnellan
Treehouse Moderator 27,696 PointsQuestion updated with code formatting. Check out the Markdown Cheatsheet below the Add an Answer submission for syntax examples.