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 trialtomd
16,701 PointsCreate a max() fuction challeng? Im so stuck. Please help.
I completed part one, but part two makes no sense to me whatsoever.
It says: Beneath the max function you just created, call it with two numbers and display the results in an alert dialog. Pass the result of the function to the alert method.
I wrote this
function max(number1, number2) { if ( number1 > number2) { return number1; } else { return number2; }
console.log(max(10, 20));
function max(number1, number2) {
if ( number1 > number2) {
return number1;
} else {
return number2;
}
alert(max(10, 20));
2 Answers
Steven Parker
231,269 PointsLooks good ... except that the final close brace to end the function is missing.
mo ode
4,352 PointsThis second task is really hard. I don't know what to do. HELP!
Steven Parker
231,269 PointsYou should always start a fresh question instead of asking one as an "answer".
But here's some hints:
- don't change the function
- call "alert" after (outside) of the function
- as the argument to "alert", call your "max" function
- pick any two numbers to use as arguments in your call to "max"
tomd
16,701 Pointstomd
16,701 PointsThank you, i have been sitting here for about an hour.... my blood pressure is so high now lol.