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 Basics (Retired) Creating Reusable Code with Functions Random Number Challenge

marcus smith
marcus smith
2,576 Points

This is not going well... cant even start it off..... :0(

is this one of those deals where only the total prodigies and super gifted only understand what he is asking?

Marcus, sometimes it seems out of reach. Some people get it faster, some (like me), get it slower. But, when I don't get something I just keep coming back to it. If it was easy-Everyone would be doing it. This stuff can be pretty hard sometimes. Breathe.

3 Answers

The math can seem a bit tricky at first, but take it one step at a time.

First, you're going to adjust your function to take two arguments.
Then, the math.random function spits out a number between 0 and 1, so you need to multiply that by the difference of your arguments + 1.
We'll need the floor of that number (hence the +1) to get back an integer.
After that you'll add the lower argument and return it. This can all be done in one statement.

Mk, I followed your steps and not only got it right, I understand it better than my first time through he course. Thank you.

^^ mkmk is spot on. Right it in "psuedo code" first.

1.) create a random number 2.) check if they guessed the right number 3.) if not check if they were too high or too low 4.) Tell them they were too high or too low 5.) check their next guess

and so on. It's not that you need to be a prodigy but you DO need to put the work in. If you just want to follow a course and be a programmer i'll save you the time and let you know that is not going to happen.

But if you are willing to put in the work you can definitely get the knowledge/understanding to make apps, get a job or freelance.

Find a local meetup or a group that meets up and hang out with like minded people that will help you SOOOOOO much.

a little harsh about putting the work in, but your layout of how to solve the issue was nice. (if he made it this far in the course he obviously is willing to put the work in)

Aaron Graves
Aaron Graves
1,849 Points

Well I didn't know where to start either. When you're new to programming sometimes you just don't know where to even begin. I started watching the video where he shows what he did and the second it made sense I stopped the video and started doing on my own. There's so many different things to learn when it comes to JavaScript especially that it's hard for some of us to remember it all.