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 trialKinkaid Nolen
4,859 PointsCreating Max
What's wrong with my code?
function max (12 , 8) {
if (12>8) {
return 12;
}
else {
return 8;
}
}
Kinkaid Nolen
4,859 PointsThanks alot!
2 Answers
Steven Parker
231,271 PointsFunction parameters may not be numbers. They are effectively variables, and follow the same variable naming rules. So replace the numbers with names and you should pass the challenge.
Numbers can be passed as arguments later when you call the function.
Kinkaid Nolen
4,859 PointsI changed them to variables and gave those variables values, but it's still not working.
Steven Parker
231,271 PointsThe variables should only get values when the function is called. They should not get values in the function definition.
If that hint doesn't clear it up, show what the code looks like now.
DULEX CHERENFANT
1,797 Pointsfunction max (num , num2) {
if (num>num2) {
return num;
}
else {
return num2;
}
}
this code should work.
<noob />
17,062 Points<noob />
17,062 PointsYou need to supply the fucntion 2 arguments such as num and num2. then u check if num is greater than num 2, if it doesn't u return num2.