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 trialDouglas Bantz
1,884 PointsFunctions and testing 2 numbers
Stuck -
function max(2,3){ if (2>3){ return(2): } else{ return(3); } }
I get a parse error. Any help appreciated
function max(2,3){
if (2>3){
return(2):
}
else{
return(3);
}
}
1 Answer
Chyno Deluxe
16,936 PointsA couple things are wrong in your code. First, the function needs to have two parameters. Like this.
function max (num1, num2) {
};
Then you need to test which of the two is greater.
function max (num1, num2) {
if (num1 > num2) {
return num1;
} else {
return num2;
}
};
Hope this helps.