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.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Create a max() Function

Tina Maddox
Tina Maddox
28,102 Points

Hello Treehouse, I would appreciate some 'fresh eyes' to look at my code. I cannot figure out what I am missing.

I am sorry for the repeated question as it has been asked

I have searched the forum, and implemented the solutions I found but they are not working either.

Thank you in advance for your help.

script.js
function max (num1, num2) {
  if (num1 > num2) {
  return num1;
  } else {
  return num2;
  }

}

alert (Math.random (max));

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Tina;

You are passing in a variable, not the max() function into the Math.random() method. Try that minor typing change, which results in a major program change, and see it if helps.

Ken

Tina Maddox
Tina Maddox
28,102 Points

Oh my goodness, Ken!

I finally got it! After five days!!!!!

Thank you SO MUCH! =D

Tina

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Tina;

Way to stick with it! Sometimes it just takes another pair of eyes. :wink:

Happy coding.

Ken