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

Dan Spector
Dan Spector
1,979 Points

Not sure why this function isn't returning correctly?

I know the numberOne and numberTwo parameters (is that what these are called?) aren't being identified correctly, but I'm not sure what I'm doing wrong? I'm sure it's a simple syntactical error, I just can't figure it out!

script.js
function max(numberOne,NumberTwo) {
  if (numberOne > numberTwo) {
    return numberOne;
  }
  else {
    return numberTwo;
  }
}
Andy Simmons
Andy Simmons
Courses Plus Student 3,734 Points

Names of things in Javascript, in your case parameters, are case sensitive.

In the first line you declare a parameter called NumberTwo but inside the function you are trying to work with a local variable called numberTwo, which your function doesn't know anything about.

2 Answers

Tony Nguyen
Tony Nguyen
24,934 Points

Hey, what's up.

Yeah, it's a syntactic error. Check your code again and check your capitalization for your arguments. Keep in mind that capitalization matters for your arguments.