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 trial3 Answers
Marina G
11,320 PointsHere is an example
function max(a, b) {
if (a > b) {
return a
}
else {
return b
}
}
So when you later call the function with any numbers you want, like:
max(5,6);
max(9,4);
it will always return the greater number.
Marcus Parsons
15,719 PointsYou have it almost all the way correct. You'll want to take out the "max" function call within the "max" function because that's invalid. You will also need variables to check instead of explicit numbers. What if the user wants to check if 8 is greater than 7? Replace 5 and 6 with your own variable names, and you'll be in business.
Marina G
11,320 PointsThanks.
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsAlthough your answer is correct, the reason we do these challenges is so that we will learn how to write out code intuitively, not copy and paste what is given to us. If everything is simply handed to us, we won't learn anything, which is why I dropped hints on how to solve it, instead of just giving out the answer to be copied and pasted. It is good that you know the answer, but you will foster a better learning environment by posting hints, instead of full code. Thanks!
Marina G
11,320 PointsMarina G
11,320 PointsHi, Marcus. Iβve heard and proved that the best way to learn and understand something is through examples, and that is what I was trying to do, help him understand with an example. Itβs his decision whether he will look the example and try to recreate his own solution or just copy and paste it. If you think that is better to learn the hard way by following unclear instructions, that will confuse you even more, which is what you did, that is just your way of seeing things. This is a forum where members ask for help and we offer it to each other. So, it is very impolite from you to tell me how to answer questions and offer my help, just because I offer a different approach than you. There are no instructions on what kind of answers we are supposed to be giving (hints or examples), so we offered him 2 options to choose from. I donβt see the point of your comment.