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

Matt Gaboury
Matt Gaboury
Full Stack JavaScript Techdegree Student 1,540 Points

I am unsure how to complete this challenge

I am struggling to figure out how to return the function to see which of the two numbers is larger. I am not sure what this challenge is asking me to do and what it should look like.

function max(10, 20) {
  return max

1 Answer

You're using numbers instead of names for your arguments. Trying changing the 10, 20 to one, two. The challenge says you can name them whatever you'd like so it technically doesn't matter (as long as they're not numbers)!

Once you have that, try using an if-else conditional statement to see which one is bigger and then return it. Right now your code is trying to return a variable named max which doesn't exist.