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.

Thaddeus Lorenz
3,434 PointsCan someone help me find the problem?
For some reason, my first task doesn't work after trying to complete the second task. Can someone please help me figure out what I'm doing wrong?
function max( a, b) {
return (a,b);
if (a > b) {
return max(a);
} else {
return max(b);
}
}
3 Answers

cortneytaylor
9,561 PointsThe return in Javascript ends the function, so anything after your first return statement doesn't run. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return

Sean T. Unwin
28,660 PointsWithin function max
:
// pseudocode
// Conditional: Is a greater then b
// yes: return a
// no: return b

cortneytaylor
9,561 PointsJust remove your return statement on line 2 and it should work.
function max(a, b) {
if (a > b) {
return max(a);
} else {
return max(b);
}
}

Thaddeus Lorenz
3,434 PointsThank you for responding but it's saying that I don't have a function named 'max()' anymore.
Thaddeus Lorenz
3,434 PointsThaddeus Lorenz
3,434 PointsHow am I supposed to have both returns at the end of the entire function with an "else" separating the function?