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 trialDan Fris
918 PointsMy Solution. Very different, but is it less efficient?
Here's my solution
https://teamtreehouse.com/workspaces/9309072#
It seems to work like it's supposed to but it's so different from the instructors. Any helpful tips or criticism would be greatly appreciated. Thank you!
3 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Dan,
Unfortunately, you can't just paste the link to your workspace. Unless you are on-line and currently in that particular workspace, the rest of use will just get the Bummer 404. You can, however, take a 'snapshot' of your workspace and post that.
In programming, there are always many ways to come to the same conclusion. No one is 'more' right than the other. As long as it works in all circumstances, makes sense to you now, makes sense to another coder. will make sense to a 'future' you, and maintains DRY expectations, then your code is correct. (There are probably many other things to consider to, but that the gist of it).
Keep experimenting and Keep Coding! :)
Jason Anders
Treehouse Moderator 145,860 PointsYour code works and you did it in 3 lines. It is a little condensed, but still makes sense and works, except you need to change one thing.
Right now it is returning a random number, but not always within the scope of the user's inputs. This was just a mathematical error and an easy fix.
You are multiplying the lowNumber and highNumber variables, when you should be subtracting the lowNumber from the highNumber to keep the result within the bounds of the low and high choice.
So instead of...
document.write(Math.floor(Math.random() * parseInt(lowNumber*highNumber)+1));
have...
document.write(Math.floor(Math.random() * parseInt(highNumber - lowNumber)+1));
Thank-you for sharing! :)
Dan Fris
918 PointsAh jeez, my apologies, I'm still getting used to the website, I see what you mean about the "Snapshot" feature. Hopefully I've done it correctly.
Jason Anders
Treehouse Moderator 145,860 PointsNo Worries, got it know. See next answer.