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 trialQasim Rashad
Front End Web Development Techdegree Student 7,837 PointsTricky question
So I've follow step by step to properly do this function and I cam across the alert section and I follow each step and shows error on the screen, did I miss something?
function max (width, height){
return height;
max( width, height)
alert( max (width, height ));
}
2 Answers
Clayton Perszyk
Treehouse Moderator 48,850 PointsHey Qasim,
You need to check if height is greater than width, and return which is larger. To do that you need to compare the two values. You will also need an if statement.
Clayton Perszyk
Treehouse Moderator 48,850 PointsHey Max,
You need to return which is larger. To do this, you could add a variable to assign the max value, or you could return from within the if clause. You will however need an else clause. Basically, if upper is greater than lower, return upper, else return lower.
Max Botez
5,146 PointsMax Botez
5,146 PointsHi Clayton, Look, I struggle to do this challenge as well. Look at my code, please.
here it seems to be ok, but it's not working :( or I miss something