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

My code for part 1 is basic but seems to work, is it ok?

var userNumber = prompt('Give me a number, any number'); var userNumber = Math.floor(Math.random() * userNumber) + 1; parseInt = userNumber; document.write('Your random number is ' + userNumber);

It seems a bit crude compared to Dave's code but it worked and I felt good about it. I didn't use 'input' as a variable though and I feel like I missed something out. Does this matter?

2 Answers

Variables can be any name that you want, so no it does not matter if you did not use 'input' as your variable name. As a good practice, it is best to use variable names that make sense with your code, and what they are holding.

Since there is no reference to Dave's code in this question, I am unsure if you missed something, however there are many different ways to solve a problem, and every programmer has their own style, so if you code worked fine with no errors then there is nothing to worry about.

Thanks for the response Amber, appreciate your words of encouragement.