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

Creating a max() function JavaScript basics

Hi all,

I have tried a different conditional statement in my code but I get a syntax error. How am I suppose to get the return value to return me the bigger number of the 2 arguments in the parameter?

Please help. Thank you

script.js
function max( numberA, numberB) { 
  if ( numberA >== numberB) {
    return numberA;
  } else if (numberA <== numberB)
    return numberB;
}

2 Answers

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

There is no operators >== or <==. If you wanna use greater then and less then, corect is <= and >=

You can find more info here - http://www.w3schools.com/js/js_operators.asp (in subtopic JavaScript Comparison and Logical Operators)

Oh my goodness, yes! Thank you so much Sergey for pointing that out, the problem is solved!