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 trialJason Styron
Courses Plus Student 955 PointsFunction Challenge
I keep getting a bummer message on this challenge with the question Did you pass 2 numbers to the max() function? I guess I am challenged myself because I am totally not getting this section, I thought I was passing the information inside the parenthesis when I called the function.
function max(lowest, highest) {
return highest
}
max('40,50');
alert('50 is higher than 40');
1 Answer
taha boubker
Courses Plus Student 1,114 PointsSorry but you didn't compare the two parameters which one is higher ; try this :
function max(a, b) {
if (a < b) { // if a is lower than b
return b; // we return b
} else { // if a is the higher number
return a; //we return a
}
}
alert(max(40,50)); // using alert to make it show the higher number : 40 or 50
Jason Styron
Courses Plus Student 955 PointsJason Styron
Courses Plus Student 955 PointsThank you. Seeing the code displayed like this makes sense to me now.
taha boubker
Courses Plus Student 1,114 Pointstaha boubker
Courses Plus Student 1,114 Pointsyou re welcome, keep up the great work buddy