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

Luis Paulino
PLUS
Luis Paulino
Courses Plus Student 1,779 Points

What do I do know?

I need help finishing this exercise. It says that I have to display it out side the function, and it just doesn't work. Let me know if you need more information.

script.js
function max(five,eight){
  return eight;
}

1 Answer

Brent Suggs
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Brent Suggs
Front End Web Development Techdegree Graduate 21,343 Points

Well the function you have written isn't complete yet. The challenge wants you to create a function that will take two parameters (numbers), determine which parameter is larger and then return the value of that parameter. Remember that when you declare the function that the parameter names are just placeholders for the actual values that you will provide the function when called upon.

for example:

// function declaration 
function greaterThan(placeholder) {
    if (placeholder > 2) {
         return placeholder;
    }
}
// function call 
greaterThan(5);