Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Hui Zheng
Courses Plus Student 1,380 Pointsfunction max(big, small){ if(big < small){ return big; }else{ return small; } alert(max(12, 10));
I followed the instructions to write out this code but I kept getting the syntax error message. I have no idea of what I
function max(big, small){
if(big < small){
return big;
}else{
return small;
}
alert(max(12, 10));
3 Answers

rydavim
18,798 PointsThe parse error is due to missing a closing curly-brace at the end of your max
function. Adding that in should get you to a more helpful hint about your solution on the challenge page.
function max(big, small){
if(big < small){
return big;
}else{
return small;
} // closes the else
} // one more here to close the function
alert(max(12, 10));
If you run into trouble though, let me know and we can walk through a solution. Happy coding!

KRIS NIKOLAISEN
54,739 PointsTwo things:
1) You are missing a closing bracket for your else statement
2) The function should return the larger of the two numbers.

Hui Zheng
Courses Plus Student 1,380 PointsCan't believe I had overlooked it. Besides the closing bracket everything else on the code was good right?
Thank you Maim

Hui Zheng
Courses Plus Student 1,380 PointsIt works now. Thanks so much for the help everyone
Hui Zheng
Courses Plus Student 1,380 PointsHui Zheng
Courses Plus Student 1,380 Pointsfunction max(big, small){ if(big > small){ return big; } else { return small; } } alert(max(12, 10)); I revised the code to this, but afterwards I still received the syntax error.