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 trial

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

JavaScript Basics Challenge Help

I passed this challenge, but was it meant to be this hard/complex? I feel like I was somehow overdoing it, and the solution was something more obvious that slipped my mind. Am I missing something? Here is my code.

function max ( x, y ) {
  if ( x > y ) {
    return x; 
  } else if ( y > x ) {
    return y; 
  } else {
    alert('Please enter two numbers that are different.');
  }
}

alert ( max ( 2, 4 ) );

Your code is missing

Sorry, fixed.