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

Allison Kuehn
Allison Kuehn
10,772 Points

Really struggling with this one, any guidance would be appreciated.

I set it up as a conditional statement, but have no idea what to put in the block code for the "if" and "else" statements.

script.js
function max (5,10) {
  if {
    5=false;
  } else {
    10=true;
  }
}

max();

If this doesn't make sense let me know, I can go through it line by line. What you did was clever but It looks like you were mixing in a few different concepts. They all get jumbled together sometimes. It will become clearer.

1 Answer

function max(a, b){
  if(a>b){
    return a;
  }else {
    return b;
  }
}
alert(max(5, 3));

Thank you for your answer I was stuck on this as well.