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.

Thaddeus Lorenz
3,434 Pointswhat am i doing wrong?
Im guessing from the problem that you need to have a random number selected then determine which number is bigger than the other. I tried the randomNumber variable to see if that would work but it's not working for some reason. Please help me.
function max ( one , two ) {
var randomNumber= Math.floor(Math.random() > two) +1;
if (randomNumber); {
alert("Congrats");
} else {
alert("Nope");
}
return max;
2 Answers

Steven Parker
216,083 PointsThere's nothing random about this challenge.
The function you create for task 1 should only compare the two argument values with each other, and return one of them based on that comparison. It also won't need to do any alerts.
In task 2, you'll write some code after the function that will use it in an alert. The instructions show an example of how to use alert to return the value of a function, and it uses Math.random() in the example, but that won't be what you use.. You'll call your own max function instead.

Jonathan Hellstrand
4,216 PointsAlong with what Steven said about task one, I noticed you have a semi-colon after your if statement:
if (randomNumber);<-- {
If you remove this, you would at least get your alerts.
Thaddeus Lorenz
3,434 PointsThaddeus Lorenz
3,434 PointsI understand what you are saying for the alert message, but I am stuck on the part where I have to compare the two argument values and creating the conditional statement to compare them.
Steven Parker
216,083 PointsSteven Parker
216,083 PointsA simple inequality comparison between items named a and b might look like this: