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 trialJacob Tennyson
6,240 PointsWhat am i doing wrong?
help
function max(10,20){
if(10<20){
return(20);
}else{
return(10);
}
2 Answers
George Zabel
5,194 PointsThe question wants you to use variables instead of actual numbers as an input. So, you'd start with
function max(num1, num2){
and go from there. Let me know if you need additional help!
Please upvote and mark as best answer if this was helpful!
LaVaughn Haynes
12,397 PointsI assume you want your function to take 2 numbers and return the bigger number? If so
//use variables in your function
//instead of numbers
function max(num1, num2){
if(num1 < num2){
return(num2);
}else{
return(num1);
}
}
//call the function with numbers
alert( max(10, 20) );
I alerted the results of using the function but you can also just store the bigger number in a variable and use it later
var biggestNum = max(10, 20);
Jacob Tennyson
6,240 PointsThanks!