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

Benjamin Lowry
Benjamin Lowry
7,941 Points

Im sure it is a simple fix...

Can someone take a look at this for the code challenge and let me know what I'm doing wrong? I know I need a conditional statement but I guess I am not implementing it correctly?? Thanks!

script.js
function max (100, 200) {
  if (100 > 200) {
    return 100;
  } else if (100 < 200) {
    return 200;
  }
}

1 Answer

Maxime Duhamel
Maxime Duhamel
7,169 Points

Hi Benjamin, I think your problem is in the way you declare your function. You shouldn't have a white space between your function name and its arguments. function max(100, 200) <<<---

Otherwise if you think about your "else if" statement, it is not necessary. Else will be enough as you comparing only 2 values.

I hope it helps.

Max