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!

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 trial

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,412 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.