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

can somebody help me find Syntax Error: Parse error?

it is the variable answer

script.js
function max( width, lenth){
 var answer = if(length > width){
  return length
}else if( length<width){
  return width
}
return answer;
}

1 Answer

Steven Parker
Steven Parker
229,644 Points

This appears to be the fourth question on the same issue. But you still haven't applied one of the hints I left you on the first one. It was:

  • you'll only need one inequality comparison for this task

And here's a few more:

  • an "if" statement does not create a value that you can assign
  • you don't need the variable "answer"
  • you also won't need the third "return" after you remove the second conditional

You're pretty close now, I bet you'll get it this time.

thank for the help the other questions were old but I didn't know how to delete them. I have completed using some of the tips u gave me and deleting a couple things

Steven Parker
Steven Parker
229,644 Points

No problem, the system will only let you delete a question that has no answers. But you can always edit a question or add comments to it instead of creating a duplicate.