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 trialAdam Lawler
3,377 PointsI can't figure out how to write a code that compares two values and returns the highest value to the function
I can't figure out how to pass this test. Having a hard time understanding the question and determining the proper code
function max(low, high) {
var largest = largest()
if (low < high){
max = high;
} else (low > high) {
max = low;
}
}
return max;
2 Answers
Abe Layee
8,378 PointsYou're so close , but you want to pass a number when you call the function. Also use the return method
function max(low, high) {
var largest = largest()
if (low < high){
max = high;
} else (low > high) {
max = low;
}
}
return max;
You want something like this
function max(low, high) {
if (low < high){
return low
}
else {
return high;
}
}
max(10,20)// 10 is for low and 20 for high
Abe Layee
8,378 PointsYou're welcome bro:D
Adam Lawler
3,377 PointsAdam Lawler
3,377 PointsThank you for the help and explanation