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 trialHui 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,814 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,971 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.