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: create a max function Please help me to see what my syntax and parse errors are.

function max (arg1, arg2) { if (arg1 > arg2) { return arg1; } else if { return arg2; } max (7, 3);

function max (7, 3) {
  if (7 > 3) {
    return true;
} else if {
  return false;
max (7, 3);

2 Answers

Steven Parker
Steven Parker
221,322 Points

When you define a function, the parameters must have names, which cannot start with (or only be) digits.

And for a "max" function, the returns need to pass back one of the parameters, not just "true" or "false".

Also, the final "else" does not need an "if" after it.

Thank you so very much! I felt like I was experiencing something similar to Imposture Syndrome. Although I'm not a professional developer yet I felt like I understood things as I learned them, then this challenge gave me a huge brain freeze.