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 trialcharlie pollard
6,471 Pointsi'm trying to produce the return value of this function code in an alert message, not sure whats going wrong here
I know the function works correctly, however not sure how i'm messing up asking to put the result into an alert box. It keeps saying I haven't applied the numbers or theres a syntax error.
function max (width, height) {
if (width > height) {
return width;
} else {
return height;
}
}
alert(max());
max(15,10);
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Charlie,
You're on the right track.
Right now, you're calling the max
function twice. Once inside the alert
method (which is correct), but you aren't passing in the values. Then the function is being called again outside the method, and the values are being passed in there. However, the instruction want the max
function called inside the alert
with the values passed in.
So, you really just need to kind of combine the two calls you have into one. Delete the last one, but add the values to the first one.
Nice work! :)
charlie pollard
6,471 PointsPerfect! That totally makes since, thank you for helping clear up that communication error for me Jason!