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 trialThaddeus 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
231,269 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
231,269 PointsSteven Parker
231,269 PointsA simple inequality comparison between items named a and b might look like this: