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 trialDJ J
Courses Plus Student 1,960 PointsNot returning a number?
function max(int1, int2) { if (int1 > int2) { return int1; } } max(10000,13);
Receiving an error that my code is NOT returning a number.
function max(int1, int2) {
if (int1 > int2) {
return int1;
}
}
max(10000,13);
3 Answers
Chyno Deluxe
16,936 PointsYou need to return a number regardless of if the 1st number is larger.
function max(int1, int2) {
if (int1 > int2) {
return int1;
} else {
return int2;
}
};
max(10000,13);
DJ J
Courses Plus Student 1,960 PointsApparently, this was the correct way. Why I don't really understand...
function max(int1, int2) {
if (int1 > int2) {
}
return int2;
}
max(10000,13);
Chyno Deluxe
16,936 PointsIt might have passed the challenge but as long as you understand why this wouldn't be best practice in a real world project then you should be fine. Code Challenges here are weird sometimes. haha
DJ J
Courses Plus Student 1,960 PointsYeah you're right lol. Quick question, how did you include the code in the code box like that?
Chyno Deluxe
16,936 Points*How to Post Code
DJ J
Courses Plus Student 1,960 PointsDJ J
Courses Plus Student 1,960 PointsThe exercise asked for the larger number to be returned, my function is returning the larger number. I checked it in the chrome console, but I am still being told that I am not returning a number.