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

stuck on this one for a weeks or so now!

I've been stuck on this for a while now. i've used MDN, and slack groups to try and lean me in the right direction.

script.js
function max (one, two)
  if (one > two) {
    return one
} else {
  return two
}
max (15,5);  
Reggie Williams
Reggie Williams
Treehouse Teacher

Hey Lewis Taylor very nice work with the logic of the program. Just make sure you're using the correct syntax function name(){}

1 Answer

Steven Parker
Steven Parker
231,269 Points

It looks like you are just missing the braces needed to enclose the function body:

function max (one, two) {  // <-- starting brace of body
  if (one > two) {
    return one;            // <-- ending statements with semicolons is a "best practice"
  } else {
    return two;
  }
}                          // <-- ending brace of body

Also, you won't need to call the function until task 2, but then you'll need to use it inside another call to log the output.