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

Not understanding the question

I don't quite understand what to do here. Would anyone be able to help clarify without giving me the answer. Any help would be greatly appreciated.

script.js
function max(2, 5) {
 if (max === 5);
}

2 Answers

Steven Parker
Steven Parker
231,236 Points

When you create a function, the parameters are names that act as placeholders for the actual values that will be passed to it later. Your parameter names must follow the same rules as variable names, so they cannot be numbers.

Then, you will need to compare the parameters to each other so you can return the one that is larger.

Thank you guys!

Hey Daniel

First of all, the arguments should be called something like numOne and numTwo not actual numbers.

If numOne is greater than numTwo then return the largest number "else" return the other one.

Sorry i'm trying to help and not give you the answer at the same time :)

Let me know if you have any further questions

Happy coding

Paul

Thank you!