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

Gareth Partridge
Gareth Partridge
6,298 Points

Create a new function named max which accepts two numbers as arguments (you can name the arguments, whatever you would l

I am getting syntax errors, does anyone perhaps see something I dont?

script.js
function max(12, 3)        
    if(12 > 3) {  
    return 12; 
  } else {
    return 3;
  }
}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 46,226 Points

Despite the instructions you can't name the arguments/parameters whatever you like. Follow the naming conventions for variables and you should be good. See JavaScript Identifiers here

You are also creating a function whose purpose would be to handle any input. Not just 12 and 3.