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 trialmelissakeith
3,766 PointsMy code won't run
function randomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}
var counter = 0;
while (counter < 10) {
var randNum = randomNumber(6);
document.write(randNum + ' ');
counter += 1;
}
11 Answers
pauladams2
8,399 Pointsmelissakeith your script call in the index.html is wrong
you have the following in you code <script src="js/random.js"></script>
You need to change it to; <script src="random.js"></script>
ahyuursagv
18,371 PointsDid you make sure and put the script tags in your html?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Let’s Make Random Numbers</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Let’s Make Random Numbers</h1>
<script src="scripts.js"></script>
</body>
</html>
melissakeith
3,766 PointsYes, this is what I have and it doesn't run, neither does the random number challenge part two. https://w.trhou.se/mo7pz7kfng
Cristiana Oliveira
3,207 PointsIts happening the same with me.
Cindy Lea
Courses Plus Student 6,497 PointsYour code seems correct. Whats not working?
melissakeith
3,766 PointsWhen I preview it, it doesn't run. It just says "Let's make random numbers", I've already tried restarting workspace and as far as I can see its exactly like the code in the video.
Sharad pareek
Courses Plus Student 681 Pointssame with me
melissakeith
3,766 PointsSeems to be a problem with Workspace, it just happens randomly, that the code looks fine and it still doesn't work.
Ernesto BELTRAN
212 Pointssame here!
Isabella Tan Hui Huang
3,577 PointsSame here!
Jenn Glas
9,475 PointsIt's happening with me, as well, but I'm using Atom as for my workspace.
Joseph Carrillo
2,137 PointsI had my condition opposite to what should be. I had the greater than symbol versus the less than symbol. This is what was breaking my code.
Wrong: while (counter > 10 ) {
code
}
Right: while (counter < 10 ) {
code
}
Taqwa R
1,852 PointsSame thing is happening with me as well. I'm guessing it's a bug.
Mary Voigt
6,591 PointsSame is happening with me https://w.trhou.se/azdl68wj7l