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 trialDiana Tiffany Bosso
3,188 PointsI am not sure was is wrong with my code can someone help me please.
Plus, can someone explain to me the difference between an alert for example and return please
function max(10, 90) {
if (90> 10) {
return 90
} else {
return 10
}
}
2 Answers
Matthew Long
28,407 PointsThere are a couple issues with your code. Mainly, you are passing in actual values instead of parameters. You will pass in the actual values such as 10
, and 90
when you call the function. Secondly, you forgot your semicolons after the return statements.
function max(a, b) {
if (a > b) {
return a;
} else {
return b;
}
}
alert(max(2, 6))
An alert is like a popup. A message box. A return statement is used to exit a function and "return" a value to use elsewhere.
Diana Tiffany Bosso
3,188 Pointsthanks I understand now.