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

Function doesn't seem to work. It should return the larger of the two numbers.

Can you help me with my code please? I am supposed to return the larger of the tow numbers.

script.js
function max ( width, height ) {
  var width = 10 ;
  var height = 20;

  return height;
}

1 Answer

Steven Parker
Steven Parker
231,109 Points

Here's a few hints:

  • Your function should not create new variables, it should use the variables that are passed in.
  • The variables passed in will already have values, your function will not assign them.
  • Your function will compare the two values to see which one is larger and then return that one.