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 trialjavier klijnjan
5,409 Pointsi'm not following this excersice, i'm not sure what i have todo after giving the 2 parameters to the function
should i use two variables inside the max function assigning a number for each one?
function max(mayor, menor){
if(mayor > menor){
return max;
}
}
1 Answer
Emmanuel C
10,636 PointsHey Javier,
Its asking you to create a function named max that took 2 arguments and returned the largest of the two. You got it mostly right if major is greater than menor you would return major since thats the largest. You also can check for the opposite, whether menor is greater than major or you can just add an else
function max(mayor, menor){
if(mayor > menor){
return mayor;
}
else {
return menor;
}
}