One Solution2:45 with Alena Holligan
Now that you've coded your solution to the practice problem, I'll show you how I did it. Remember, there are almost always more than one way to solve a problem.
We're looking for feedback on this new type of practice workshop. When you're finished, could you please review the workshop by filling out this short form? We appreciate it!
How did you go, were you able to complete the challenge? 0:00 If not, no worries, you can watch my solution, 0:04 compare to what you wrote and then try the challenge again. 0:07 The first step was to create a variable named myLines, and 0:11 set it's value equal to the integer 4000000 dollar sign, 0:15 my lines equals 4 followed by 6 zeroes. 0:20 Step two. 0:25 Use an if statement to check whether my lines is greater than osx. 0:27 If my lines is greater than osx we echo the string. 0:32 If you wrote the first if statement with a closing curly brace, 0:39 you will need to remove that curly brace for the next elseif line. 0:43 Step three, 0:48 add an elseif statement to check whether myLines is greater than Android. 0:49 And if so, display the string. 0:54 elseif my lines greater than android. 0:58 Echo the string. 1:02 Again, watch your curly brace. 1:05 Step four. 1:07 Add another elseif statement to check whether my lines is greater than 1:09 Apollo 11, and if so display the string. 1:13 elseif my lines are greater than Apollo 11. 1:18 Echo this string. 1:21 Step 5, add an else statement to display this string. 1:24 else echo, and this time we make sure we include our final closing curly brace. 1:30 Step six, is to test your code by changing the values of myLines. 1:38 Let's give it a try. 1:45 Now, we'll change the myLines variable and run the code again. 1:57 You can push the up arrow. 2:03 Once again, change the myLines variable. 2:07 And run. 2:16 And one last time. 2:18 Change the variable, and run the script. 2:20 If your solution was different than mine. 2:27 That's great. 2:29 Seldom is there only one solution. 2:30 If you see something interesting in my code 2:33 you should try implementing it in your own program. 2:36 Keep practicing, so you can master these new skills. 2:39 Until next time, happy coding. 2:42
You need to sign up for Treehouse in order to download course files.Sign up