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 trialKyle Gibbons
1,388 PointsHello, I'm confused on why my code is not printing out random numbers ?
function randomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}
var counter 0;
while ( counter < 1000) {
var randNum = randomNumber(7);
console.log(randNum + ' ');
counter += 1;
}
2 Answers
Jennifer Nordell
Treehouse TeacherShort answer? You're missing an equals sign
Change this:
var counter 0;
To this:
var counter = 0;
You will soon be flooded with 1000 random numbers just like I was
Matthias Nörr
8,614 PointsWhat does the "7" inside the randomNumber function mean again?
var randNum = randomNumber(7);
nico dev
20,364 PointsIt's an argument that will give you a random number from 1 up until 7.
About passing arguments to functions, this is the best explanation I've ever seen. Feel free to check back again that video, and if you still have doubts, get back. :)
A X
12,842 PointsA X
12,842 PointsOh the littlest things! They really do make all the difference!
Kyle Gibbons
1,388 PointsKyle Gibbons
1,388 PointsThank you, yes a very little thing. I went up and down it 10 times and couldn't find what was wrong there, I appreciate the help.