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 trialJulien Arseneau
Full Stack JavaScript Techdegree Student 5,200 PointsCan someone explain to me how to do this challenge, please?
I do not understand how to return my arguments.
function max(x, y)
var sink = x * y
if (x > y) {return x;}
else {return y;}
2 Answers
Steven Parker
231,269 PointsBrandyn's suggestion of enclosing the function body in braces is correct, and should get you past task 1.
But the line creating the variable named "sink" doesn't seem to do anything for the function and while it doesn't prevent passing the challenge it really shouldn't be there.
Brandyn Lordi
17,778 PointsBrandyn Lordi
17,778 PointsYou also need to wrap your function in curly braces and end each line 2 with a semicolon, then you simply need to call the function and pass through your parameters.
Also, it looks like you are defining
var sink = x * y
but you aren't doing anything with it.Your code should look like this:
Part 2 of challenge
alert( max(2,5) );