Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Create a max() Function

Challenge Task 1 of 2 for Giving Information to Functions

Good evening, I am trying to create a max() Function with two arguments. The exercise states that I need to create an IF statement to test which number is the larger of the two arguments. I have tried several times to create an IF statement that will allow me to do this with no success. I create a function at the top of the program and then I write my IF statements outside of the function. Do i need an IF ELSE statement and not just an IF statement? Do I need to display an alert message saying which number is (or isn't) the max? I keep getting syntax errors every time I try to run my program.

1 Answer

Seth Kroger
Seth Kroger
56,403 Points

Sharing you code will help a lot. However I will give you the hint that the if statement needs to go inside the function, not outside it.