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

functions

please help me with this code its keeping on telling me bummer where am i wrong here please

script.js
function max(5,9) {
  if (5 > 9) 
    return 9;
  } else {
    return 5;
  }

alert(max(5,9);

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Claudius! Your function must be more generic. Treehouse is going to call that function and send in numbers, so it must accept any numbers that come in and compare them. You're attempting to hard-code the values. The things inside the parentheses in the function declaration are called parameters and they must be valid JavaScript variable names like num1 or num2 for example. Then compare num1 against num2. When Treehouse runs your function they will send in two numbers. The first number will go into the num1 and the second will go into num2 (assuming those are the variable names you choose).

Also, the alert is not asked for nor required by the challenge nor the call to the function.

Give it another shot with these hints in mind! :sparkles:

thank you jenn let me try that one