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 trialHunter Shaw
2,187 PointsTrying to get the larger of the two? I don't understand this.
Help with my program to get the larger number of the two.
function max(num1, num2) {
var numbers = num1;
numbers += num2;
if (num1 > num2) {
document.write(num1);
} else {
document.write(num2);
}
return numbers;
}
max(5, 7);
1 Answer
Steven Parker
231,269 PointsYou're close. But you don't need to add the numbers together, and you don't need the "numbers" variable. Also, the function should return the largest value (not "document.write" it).
The for task 2, when you invoke the function it should be inside an "alert()" call.