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 trialElizabeth Bazan
3,007 PointsNeed help with finishing this please....
Challenge Task 2 of 2 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.
For example, to display the results of the Math.random() method in an alert dialog you could type this:
alert( Math.random( ) ); Oops! It looks like Task 1 is no longer passing. Get Help Recheck work Go to task One script.js
1 2 var num1 = 10; 3 var num2 = 1; 4 5 function max(num1, num2) { 6 alert(num1, num2); 7 } 8 9 max(10,1); 10 11
var num1 = 10;
var num2 = 1;
function max(num1, num2) {
alert(num1, num2);
}
max(10,1);
1 Answer
Ford Heacock
18,068 PointsThere are a few things I can point out that will hopefully help clarify some things for you. First, you do not need the var num1 = 10;
or var num2 = 1;
because you are passing variables dynamically when you call the function at the bottom of the file with max(10,1)
Second, you need to have the function determine which of the two numbers you passed is the higher value. Maybe you could compare the two to see if one is >
than the other? Finally, I believe the challenge is asking you to alert the result of the function, not inside the function itself. You could do this with alert(max(10,1))
See if you can figure out how to compare the two values in your function, you're close! Best of luck.
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 Pointsmoved to answer