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 trialIris Wang
Front End Web Development Techdegree Student 8,288 PointsCreating 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
function max( numberA, numberB) {
if ( numberA >== numberB) {
return numberA;
} else if (numberA <== numberB)
return numberB;
}
2 Answers
Sergey Podgornyy
20,660 PointsThere 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)
Richard Wong
Full Stack JavaScript Techdegree Student 1,888 PointsThanks very much Sergey - you helped me on this problem as well, so you got twice the bang out of this post
Iris Wang
Front End Web Development Techdegree Student 8,288 PointsIris Wang
Front End Web Development Techdegree Student 8,288 PointsOh my goodness, yes! Thank you so much Sergey for pointing that out, the problem is solved!
Sergey Podgornyy
20,660 PointsSergey Podgornyy
20,660 PointsYou are welcome ;)