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 Functions Pass Information Into Functions Create a max() Function

Anton Sigurdsson
Anton Sigurdsson
1,357 Points

syntax error (5:4)

So this is how I set it up, but I cant get past this syntax error, what am I doing wrong???

script.js
function max(high, low) {
  return high + low;
  if (high > low); {
    return high;
  } else {
    return low;
  }
}
}
max (4, 5);

1 Answer

I modify you code to work. Check it and try to understand it.

function max(high, low) {

  if (high > low) {
    return high;
  } else {
    return low;
  }
  return high + low; // this code will never RUN .
}

max (4, 5);

When a function will get a return will stop and not continue. That meen you never enter in "if"condition with your code thats why i put it down but is better to remove it ! Another error i find is after if(high > low) you put an ";" and that trow a sintax error .