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 Functions Pass Information Into Functions Create a max() Function

Bummer: It doesn't look like you used the `console.log` method.`

so, exactly WHAT am I missing here?

script.js
function max(first,second) {
  parseInt = first;
  parseInt = second;
  if (first>second) {
      return first;
    } else { 
      return second;
    }
 console.log (max (5,22));
}

1 Answer

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Full Stack JavaScript Techdegree Graduate 35,771 Points

Hi Amy,

The return keyword tells JavaScript to exit the function. As such (in your code), there is no scenario where the JavaScript interpreter reaches the console.log function. If the first argument is greater than the second argument, then the first argument is returned and JavaScript exits the max function. But if the first argument is less than or equal to the second argument, then the second argument is returned and JavaScript exits the max function. In both cases, the function is exited before JavaScript gets to your console.log statement.

If you move your console.log statement to be outside of your max function you'll pass the challenge.