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

Christopher tufano
Christopher tufano
1,259 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
217,570 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