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 trialMyles Mayfield
Full Stack JavaScript Techdegree Student 834 PointsMultiple conditional statements
I am really having a hard time figuring this one out if anyone could help id appreciate it!
Create a new function named max which accepts two numbers as arguments (you can name the arguments, whatever you would like). The function should return the larger of the two numbers.
function max () {
}
1 Answer
Alexander Davison
65,469 PointsOk... I'll try not to give you the answer directly, since the best way to learn programming is to try on your own, but I'll give you a few hints.
- You should take in two arguments:
a
andb
. You can call them whatever you want, though, as long as it is a valid variable name. For example, they can't contain spaces! - You can make an
if
/else
clause. The condition should check ifa
is bigger thenb
. - If
a
is bigger thanb
, returna
. -
Otherwise, return
b
. Tip: Otherwise means the same thing aselse
!
I hope these hints help
If you need more help, post the code that you tried below and I'll try to help more.
Happy coding!
~Alex
Myles Mayfield
Full Stack JavaScript Techdegree Student 834 PointsMyles Mayfield
Full Stack JavaScript Techdegree Student 834 PointsWould there be any specific way you would start this piece of code?? I took your and used a & b as my arguments. But later when i get to my if/else clause I try to use 2 numbers. Long story short I am apparently not doing it right haha. Any help is appreciated.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsHere's a big hint...