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 trialMohsen Ahmad
2,699 Pointsmax function help please. Isn't returning a number.
Here is the code I put:
''' function max(width, length) { if(width>length) { return width; }; } max(100,120); ''' Thanks!
function max(width, length) {
if(width>length) {
return width;
};
}
max(100,120);
3 Answers
Shane Oliver
19,977 PointsIn your logic you are passing 100 width and 120 length. Your function will only return width if it is bigger than length, which it isn't :) try swapping the numbers around to
max(120, 100) // this will return the 120 because width 120 is bigger than length 100
Mohsen Ahmad
2,699 Pointshi. Thx. but still i get "The max
function isn't returning a number." Shane Oliver
Shane Oliver
19,977 PointsThe question asks you to alert the result of the max function
function max( w, h ) {
if ( w > h ) return w;
else return h;
}
alert ( max( 120, 100 ) );