Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Create a max() Function

I can't figure out the answer.

function max(number1,number2){

if(parseInt(number1)>>ParseInt(number2)){ return number1; } if else(parseInt(number1)<<parseInt(number2)){ return number2; } }

max(1,2);

script.js
function max(number1,number2){

if(parseInt(number1)>>ParseInt(number2)){
   return number1;
}
if else(parseInt(number1)<<parseInt(number2)){
   return number2;
}
}

max(1,2);
Sandro Das Neves
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sandro Das Neves
Front End Web Development Techdegree Graduate 23,426 Points

a parse error don't need to use parseInt. you can delete them. I give you the solution try.

function max(number1,number2){

if(number1 > number2){
   return number1;
}
  else {
   return number2;
  }
}

1 Answer

Umesh Ravji
Umesh Ravji
42,362 Points

Hi Gaku

if(parseInt(number1)>>ParseInt(number2)){

Since JavaScript is case-sensitive ParseInt must begin with a lowercase P, but this was probably just a typo. Comparisons for greater than and less than are done with either > or <. What you are using, << and >> are actually bitwise operators (which I don't think are covered here).

if(condition){
   // code
}
if else(condition){
   // code
}

The proper way to structure an if else statement is:

if(condition){
   // code
} else {
   // code
}

Since the question never actually asks you to convert any inputs to integers, you can simply leave it off.

function max(number1, number2){
  if(number1 > number1){
     return number1;
  } else {
     return number2;
  }
}

thank you very much,I finally got it!!