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

What am I doing wrong?

Challenge Task 1 of 2

Create a new function named max() which accepts two numbers as arguments. The function should return the larger of the two numbers. You'll need to use a conditional statement to test the 2 numbers to see which is the larger of the two. Bummer! There was an error with your code: SyntaxError: Parse error

what am i coding wrong?

script.js
function getArea(width, length) {
  var area = width * length
  return area " " + unit; 
}
console.log(getArea(10, 20));
Chi-Shiang Wang
Chi-Shiang Wang
3,471 Points

Hi, I'm not sure, but your code does't like to find maximum from two number. if your want to find large number from two number, you need "if" to help you.

function getMaximum(num1, num2){ largeNum = 0 if num1 > num2 largeNum = num1 else largeNum = num2 return largeNum }

And in your code, there have a little bug in your "return area " " + unit "

return area " " + unit -> return area + " " + unit Please try it, maybe is work for you :-)

hoping this comment can help you solve your problem. <And.... sorry for my poor english>

1 Answer

Chi-Shiang Wang
Chi-Shiang Wang
3,471 Points

in your code, there have a little bug in your "return area " " + unit " > return area " " + unit -> return area + " " + unit Please try it, maybe is work for you :-)

hoping this comment can help you solve your problem.