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 trialashique desai
3,662 PointsHow to create a max() function?
Have written this code to solve the challenge. But the code is not working. Can anybody help please!
```JavaScript
var a = 21;
var b = 1;
function max(a , b) {
if(b < a) {
return a;
}
}
1 Answer
Steven Parker
231,236 PointsBut what if b is not less than than a?
Wouldn't you want to return b?
Also, you don't need to set values for a and b, the challenge will do that.