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 trialjustin boger
2,589 Pointsreate a new function named max which accepts two numbers as arguments
function max(10, 20) { if (10 >20) { return 10; } else { return 20; } }
function max (10, 20) {
if (10 > 20) {
return 10;
} else {
return 20;
}
}
1 Answer
justin boger
2,589 Pointsfunctions are the most confusing thing I have done so far with programming but I think I am starting to get it. It will probably make more sense when I use functions for more real work applications rather than just example exercises.
Andrew Aramouni
2,370 Pointsya Justin I agree. I was completely lost some times studying functions.
Bryan Fondrick
15,407 PointsBryan Fondrick
15,407 Pointsthink of arguments, not as literal numbers but variables because you want to be able to reuse the function more than just one time. So, you could recreate the function as: function max (first, second){ if(first > second){ return first; } else { return second; }