Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
williamrossi
6,232 PointsJavascript Basics, alert numbers
Not sure what this one needs?
Call the function and display the results in an alert dialog. You can pass the results of a function directly to the alert() method. For example, to display the results of the Math.random() method in an alert dialog you could type this:
function max(num1, num2) { if (num1 > num2) { return num1; } else { return num2; } }
alert(max(num1, num2));
Last question on the course for me to complete Javascript basics woo
2 Answers

Jeff Jacobson-Swartfager
15,418 PointsWith the previous part of the challenge, you created a max function. Now, you just need to call it in an alert. You will need to pass 2 numbers to your max function.

Francisco Santiago
9,591 PointsIf anyone needs this answered I must share my findings due to being stuck on it for a while, see below; ( I found that the only way that it worked for me was closing parentheses which I overlooked, all three must be closed for this to work) hope this helps anyone not picking up on this minor oversight:
alert( Math.random( ) ); function max( num1, num2 ) { if (num1>num2) { return num1; } else { return num2; } } alert( Math.random(max(1, 2)) );
mtch
8,521 Pointsmtch
8,521 PointsYou have to create a function and call it.
Remember the syntax of a function:
functionName(parameter1, parameter2, parameter3) { code to be executed }
Just create a random function, let's say:
function random(value1, value2) { return value1 + value2; }
//And call it by using the build in alert(); function
alert(random(4,3));
//And you'll get 7 shown in an alert box.