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 trialmichaelkyllo
11,330 PointsI honestly can't figure this out, I think my code is right.
function max(x,y) { if (x>y) { return x; } else { return y: }
max(6,8)
4 Answers
Erik Nuber
20,629 Pointsfunction max(x,y) {
if (x>y) {
return x;
} else {
return y; }
}
max(6,8)
Two small things. You need a semicolon after return y instead of a colon and, the function needs a closing bracket.
Hewan Abreha
3,796 PointsOn the top of Erik's solution, also add a semicolon after max(6,8); too. hope this helps :)
Jeremy Gonzales
8,980 PointsOdd I tried this and it worked.. <!DOCTYPE html> <html> <body>
<p>This example calls a function which performs a calculation, and returns the result:</p>
<p id="demo"></p>
<script> var a; var b; function myFunction(a, b) { if (a>b){ return a; } else{ return b; }
} document.getElementById("demo").innerHTML = myFunction(30, 3); </script>
</body> </html>
Jeremy Gonzales
8,980 PointsLooks like Erik & Hewan got this!