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

how to call two arguments....

Underneath the max() function you just created, call it with two arguments and display the results in an alert dialog. You can pass the result of the function to the alert() method. For example, to display the results of the Math.random() method in an alert dialog you could type this:

script.js
function max(x, y) { if (x > y) { return x; } else { return y; } } 
function max(x , y){
alert(x + "and" y );
}

1 Answer

Van Tran
seal-mask
.a{fill-rule:evenodd;}techdegree
Van Tran
Front End Web Development Techdegree Student 12,628 Points

I suppose that the max function should be called like:

function max(x, y) { if (x > y) { return x; } else { return y; } }

maxValue = max(5, 1); // Find the max value of 5 and 1

alert(maxValue); // alert the max value