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

Ronnel Jones
Ronnel Jones
5,043 Points

What's my Syntax Error?

I have looked at different resolutions and they say they did such and such and it worked. I tried it all and still come up with a Syntax Error. Please help!!!! Code is:

function max(10,25) { if(25 > 10) { return 25; } else { return 10; } }

max(10,25);

script.js
function max (10,25) {
  if(25 > 10) {
    return 25;
  } else {
    return 10;
  }
}

max(10,25);

1 Answer

Steven Parker
Steven Parker
231,275 Points

When you define a function you use parameter names to represent the values that will be supplied later when the function is called. You would not use actual values (such as literal numbers) in the definition.

Ronnel Jones
Ronnel Jones
5,043 Points

Thanks. I knew it was something stupid I was doing.