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 trial

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