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

create a new function called max

create a new function called max which accepts two numbers as arguments ; and whould return the larger

script.js
function max (2;4);
if ('4 is greater than 2')
return larger;

1 Answer

Mike Hatch
Mike Hatch
14,940 Points

Your syntax needs some reworking. It will look more like this:

function max( , ) {
 if ( > ) {

  }
}
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Mike Hatch! I took the liberty of changing your comment to an answer. Besides keeping the forums tidy by marking the question as "answered", it also allows for voting on your answer and possible selection of "Best Answer". Thanks for helping out in the Community! :sparkles:

Mike Hatch
Mike Hatch
14,940 Points

Okay, thank you Jennifer. Sometimes I do that with uncertainty if I'm giving a full answer or not. I'm still gauging just how much I'm supposed to help. Some students outright give the answer away, and others give more of a guide. Love all the work you do here! A big fan.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

For what it's worth, I thought that was pretty spot on :thumbsup: And thanks! Didn't know I had fans :smiley:

Michael Hulet
Michael Hulet
47,913 Points

I know Jen already responded to your comment, but I just wanted to agree with her here. This was a solid response imo. I also wanna add that the only real thing you shouldn't do when responding that isn't an immediate no-brainer is post code that can be copied and pasted into a challenge/quiz and pass unmodified. Your answer here was great, and please help as much as you're inclined to!