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 trialJoseph Gardin
4,583 Pointscreating a max() function HELP
can anybody help me with this task?? i dont even know how to start it besides naming the function....
function max (two, four) {
if {
2 Answers
doesitmatter
12,885 PointsIf you don't know how to start, try writing the solution in normal language. So something like.
Calculate max function:
- Take a value A and a value B
- If A is bigger than B then return A as the answer else return B as the answer
Thats it. Now in JS we can write this as follows:
function max(a, b){
if( XXXX ){
return XXXX;
}else{
return XXXX;
}
}
You can figure out what XXXX should be can't you?
Joseph Gardin
4,583 Pointsthanks to both of you guys. it worked.
Michael Liendo
15,326 PointsMichael Liendo
15,326 PointsYou beat me to this one! I deleted my answer since I like your approach of not giving the full answer.