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 trialColin Stell
Front End Web Development Techdegree Graduate 25,702 PointsI'm not sure where to go to figure this problem out.
Having trouble figuring this out. I'm got my parameters and what seems to be a conditional statement that should return the correct number. I'm lost. I'm working to return largest sum of whatever is put into the parameters when I call the function.
function max(num1,num2) {
if (num1 > num2) {
return num1;
} else (num1 < num2) {
return num2;
}
}
max(96,29);
1 Answer
Christian Mangeng
15,970 PointsHi Colin,
two things here:
1) The else statement does not take any condition because it already covers all of the cases that are not covered by the if statement. So you should remove that condition part. "Else" works in this case because if the numbers are equal, it wouldn't matter which of the two gets returned (num2 is fine)
2) You do not need to call the function at the end
The rest looks fine
Colin Stell
Front End Web Development Techdegree Graduate 25,702 PointsColin Stell
Front End Web Development Techdegree Graduate 25,702 PointsGreat, thank you for your help! Was able to pass the code once I removed the else condition.