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

Task makes no sense to me

don´t get what it wants me to do?

script.js
function max (num1, num2) {

  return Math.max( num1 + num2);

}

max(2, 7)

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

The first thing that you're missing is that it wants you to test what the maximum of the numbers should be by using an if condition statement.

Secondly, you're trying to use the max() method when all it wants is a function called max, which you've successfully defined.

function max (num1, num2) {
}

So next provide a way for JavaScript to check which number when called is the largest of the 2 numbers... the way to do that is with a condition statement.

Simply return a reference to those variables .e.g. return num1

I still don´t understand the task.

But i made it work now.

Thank you :-)