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 trialCasey Abbott
7,845 PointsWhy doesn't this work? I copy and pasted it into VS Code and debugged it and it works with no problems. says no function
function max (width, hight) { return max(36, 30); } if ('hight' > 'width') { alert('your ' + 'hight ' + 'is greater than your width'); } else { alert('Your ' + 'width ' + 'is greater than your hight'); }
function max (width, hight) {
return max(36, 30);
} if ('hight' > 'width') {
alert('your ' + 'hight ' + 'is greater than your width');
} else {
alert('Your ' + 'width ' + 'is greater than your hight');
}
2 Answers
Casey Abbott
7,845 PointsThank you!
Dillon Wyatt
5,990 PointsIs the goal to answer the lesson objective? I am assuming so.
First, you are returning too early. After determining which is the correct answer (the bigger number), you return only that answer.
Second, I am not sure what your alert functions are suppose to accomplish. They are not needed for the objective.
Third, you are comparing the value of two strings "height" and "weight". What you want to be comparing is the value of two integers.
So, try something like
function max (x, y){
if (x > y){
return x
}
else if (y > x) {
return y
};
};
Mathew Tran
Courses Plus Student 10,205 PointsMathew Tran
Courses Plus Student 10,205 PointsSo first part of the challenge, it's asking you to make the
max
function.Second part is asking you to wrap it in a
Math.random
function, then analert
function, like so:alert(Math.random(max(2,3)));