Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

script.js
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
220,526 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
220,526 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!