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 trial

JavaScript JavaScript Functions Pass Information Into Functions Create a max() Function

javascript 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
Steven Parker
229,920 Points

If 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.

my husband helped me through that challenge and now it's giving a new error. not sure where I'm misunderstanding things.

Steven Parker
Steven Parker
229,920 Points

Maybe hubby had just read the instructions for a different challenge with random numbers. :see_no_evil:

Start a new question where you can show your code as it is now if you need help with it.

He'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!