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 trialCarl Sergile
16,570 PointsWhat am I doing wrong?
Hey need some help>>
function max(two, four) {
if (two < four ) {
return true
}
else {
return false
};
2 Answers
Tobias Helmrich
31,603 PointsHey Carl,
there are a few problems in your code. Firstly you forgot to close your else clause, secondly you're returning boolean values instead of the numbers. The goal of the challenge is to return the bigger number. I kept your variable names and changed your code so it's working:
function max(two, four) {
if (two < four ) {
return four;
} else if(two > four) {
return two;
}
}
Also note that it would be better to use an else if instead of an else because if the two values would be equal, the else would be executed and a number would be returned even if it's not bigger. I hope that helps, if you have further questions feel free to ask them, good luck! :)
Victor Ruiz
16,570 PointsHi Carl,
So your structure is okay, but your missing the closing bracket.
function max(two, four) {
if (two > four) {
return true
} else {
return false
};
}
Hope this helps. Keep Coding! :)