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 trialnick shrake
2,251 PointsNeed help with function max task 2 of 2
Keep getting this error and not sure what to do to fix it "Did you pass 2 numbers to the max()
function."
function max (firstNumber, secondNumber){
if (firstNumber > secondNumber) {
return; firstNumber
} else {
return secondNumber; }
}
max(10,9);
alert(max(10,9));
3 Answers
Heidi Puk Hermann
33,366 PointsIf you look in line 3 in your code, you have put the semicolon after return, but before the variable you want to return. if you move the semicolon to the end of the line your code should work perfectly.
...
return firstNumber;
...
Henrik Christensen
Python Web Development Techdegree Student 38,322 Pointsfunction max (firstNumber, secondNumber){
if (firstNumber > secondNumber) {
return; firstNumber // ; is mis-placed here
} else {
return secondNumber; }
}
nick shrake
2,251 PointsOh dang idk how that happened lol thanks guys!