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 trialJeremiah Walker
2,953 Pointscreate max() function method
I tried multiple ways to beat the second step of the challenge.. can someone show me what I'm doing wrong? They want me to store the max() in the alert() dialog box, but it isn't working. Thanks!
function max(numA, numB) {
if (numA > numB) {
return numA;
} else {
return numB;
}
}
alert( max(numA,numB) );
5 Answers
Abe Layee
8,378 PointsYou're almost correct. You just have to pass a number when you call the max() function. Like this
alert(max(10,3)) // 10 for numA and 3 for numB
Nicolas Sandller
5,643 Pointsgive us some context, what is the error that pops up?
Jeremiah Walker
2,953 PointsIt ask me if I put the two number parameters inside the max() function.
Jeremiah Walker
2,953 PointsWow thanks Abraham! It worked and now I understand it better :D
Abe Layee
8,378 PointsYou're welcome:D
Jeremiah Walker
2,953 PointsWow thanks Abraham! It worked and now I understand it better :D