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 trialGaku Nagasaku
2,427 PointsI 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);
function max(number1,number2){
if(parseInt(number1)>>ParseInt(number2)){
return number1;
}
if else(parseInt(number1)<<parseInt(number2)){
return number2;
}
}
max(1,2);
1 Answer
Umesh Ravji
42,386 PointsHi 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;
}
}
Gaku Nagasaku
2,427 Pointsthank you very much,I finally got it!!
Sandro Das Neves
Front End Web Development Techdegree Graduate 23,426 PointsSandro Das Neves
Front End Web Development Techdegree Graduate 23,426 Pointsa parse error don't need to use parseInt. you can delete them. I give you the solution try.