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 trialGareth Partridge
13,421 PointsCreate 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?
function max(12, 3)
if(12 > 3) {
return 12;
} else {
return 3;
}
}
3 Answers
KRIS NIKOLAISEN
54,971 PointsDespite 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.
Mirko Aus
1,687 PointsThat's how I solved it. I wasn't quite understanding the wording of the problem so it took slightly longer than usual to solve it. As Kris mentioned, you can't define parameters as some exact numbers and words.
function max (value, value) { if (arguments[0] > arguments[1]) { return arguments[0]; } else { return arguments[1]; } }
max(1, 2); // arguments[1] or number 2 is returned because arguments[0] value is smaller than arguments[1]
chuck kotulka
4,583 PointsCreate a new function named max which accepts two numbers as arguments (you can name the arguments, whatever you would like). The function should return the larger of the two numbers.
I am stuck! Any Help?