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

Christopher tufano
Christopher tufano
1,686 Points

I'm returning a number, why is this not accepting my work? thank you

function max(one = 12, two = 6) {
  if (one >= two) {
    return console.log(`${one} is larger then ${two}`);
} else {
  return console.log(`${two} is larger then ${one}`);
max(10, 20)

1 Answer

Steven Parker
Steven Parker
228,077 Points

The instructions say, "The function should return the larger of the two numbers." But this code is logging a message instead of returning a value ("console.log" doesn't return anything).

So, for this challenge:

  • be sure to return the larger value
  • you won't need to display anything
  • you don't need to provide default values for the arguments