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 trialRaedawn Long
6,943 PointsNeed assistance getting this code started
not accepting numbers in max function
function max (4, 20) {
}
3 Answers
Jeffery Haupt
Python Development Techdegree Student 18,938 PointsTo get some clarification, are you trying to use Math.max(a,b) or a function named "max" that's trying to pass two numbers into the function?
If you are trying to use Math.max(4,20) then you have to use Math.max(4,20) to get it to return 20.
Jeffery Haupt
Python Development Techdegree Student 18,938 PointsSorry, I didn't relize that this was part of a Code Challenge. Given the code challenge you are looking at developing a function named max that accepts two arguments; here's what I did:
function max( x, y ) {
if ( x > y ) {
return x;
} else {
return y;
}
}
max(4,20);
When you call max(4, 20); then it will retrun 20 (which would go in as y)
Raedawn Long
6,943 PointsThanks Jeffery, I am trying to use function max keep getting error message
Jeffery Haupt
Python Development Techdegree Student 18,938 PointsI followed it up with my code snippet above, did you get a chance to review that?