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 trialJessica Musick-Sanchez
2,392 Pointsjavascript functions larger number challenge
pretty sure my if else statement is fine but friend couldnt explain what i did wrong in my first section of code
function getRandomNumber( a, b ) {
const largerNumber = math.random();
return largerNumber;
}
console.log(getRandomNumber(30, 50));
if ( a > b ) {
console.log(`${a} is larger than ${b}`);
} else {
console.log(`${b} is larger than ${a}`);
}
1 Answer
Steven Parker
231,275 PointsIf the page linked to the "view challenge" button is the one you're working on, you've headed in a very different direction from the instructions.
For this challenge, you will make a function named "max" to compare two numbers and return one of them.
You won't need a "getRandomNumber" function (or do anything random at all), and you won't need to log anything to the console until you get to task 2.
Jessica Musick-Sanchez
2,392 PointsJessica Musick-Sanchez
2,392 Pointsmy husband helped me through that challenge and now it's giving a new error. not sure where I'm misunderstanding things.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsMaybe hubby had just read the instructions for a different challenge with random numbers.
Start a new question where you can show your code as it is now if you need help with it.
Jessica Musick-Sanchez
2,392 PointsJessica Musick-Sanchez
2,392 PointsHe's a senior dev so I'm nowhere near his level and he hasn't done this basic of stuff in quite a while but thanks anyways and will do!