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 Basics (Retired) Creating Reusable Code with Functions Create a max() Function

Penelope Baptiste
Penelope Baptiste
2,353 Points

I got it before

any live philly. what, i'm going back and watch the videos. I'm missing something

script.js
function max(){
var a = 10
var b = 20
if b>a = max;
}
return max;
Penelope Baptiste
Penelope Baptiste
2,353 Points

if i'm not on it every day. I come back on ....am like what? ....I know I was up until 2am watchin videos. Was I asleep.

Thanks for the feedback. i was having second thought. Maybe i need more coffee for my JavaScript.

4 Answers

Jack McDowell
Jack McDowell
37,797 Points

Hello, the exercise is asking for a solution with two empty variables and a conditional, as in the following code:

function max(num1, num2) {
  if (num1 > num2) {
    return num1; 
  }
  else{
    return num2;
  }
}
Rich Donnellan
Rich Donnellan
25,767 Points

I gave a detailed answer in another post asking the same thing. You can check it out here.

<rant>It's not your fault, but Treehouse needs to figure out a better way to incorporate these forum questions/solutions in the challenge activities, as it's getting tiresome seeing/answering the same questions on the daily. </rant>

Ryan Carson?

–Rich

Then take a break, Rich. Let some of us who are still struggling to figure this stuff out answer questions for others. I get a ton out of it when I'm able to find a question I can answer, but you beat everyone to the punch on almost all of the JavaScript stuff. If you're bored with it, pick a new language to learn, maybe? Answering questions isn't just about being an expert, it's about learning something along the way.

Jack McDowell
Jack McDowell
37,797 Points

Brian, not to mention that Treehouse wants you to help others out and participate in the forum at least up to 60 points. If they got rid of people answering questions to challenges I'm sure we'd get a lot more people simply posting random questions and answers like they do on Yahoo answers! Then again, Rich might be trying to steal my best answer points ;)

:)

Rich Donnellan
Rich Donnellan
25,767 Points

Gents,

By no means am I:

  • an expert
  • bored with JavaScript
  • trying to steal Jack McDowell 's best answer
  • purposefully sounding like a dick

My rant was merely a suggestion (albeit in the wrong place) to provide past question(s)/solution(s) in a more accessible place. This could reduce the repeat questions and give the students a chance to become more self-reliant.

Cheers!

–Rich

Jack McDowell
Jack McDowell
37,797 Points

Rich Donnellan, to be honest I have to say that a better way of grouping the answers would be useful. I've found myself spending more time trying to look up the challenges to some of the questions here than actually answering them, although some of them do show up on the right under course.

Following your suggestion, perhaps doing the reverse would be useful for pointing students to the current forum questions for that challenge, since the website appears to have a mechanism for linking the forum posts and challenges together.

And I do think that your answer was better, I'm just getting back into JS myself.

I read somewhere that the written word communicates less than 10% of our intentions.

Many apologies, Rich. My intentions were not to accuse you of any of the things you listed above.

Rich Donnellan
Rich Donnellan
25,767 Points

All good, man; we cool!

Sorry to Penelope Baptiste for hijacking her post! Haha!

Penelope Baptiste
Penelope Baptiste
2,353 Points

I thing am reading into the questions too much...

Rich Donnellan
Rich Donnellan
25,767 Points

Understandable! It'll get easier.

Hope my example was clear. :-)

Rich Donnellan, thanks for tagging me.

Kyle Meyer is now in charge of the UX here so I'll let him share his thoughts.

Thanks for being a Treehouse Student!