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 trialalee2
5,435 PointsWorkspace preview causes chrome to hang
Again, an issue where my code matches the solution code yet my result is different. In this case I have refactored the code to the below. which matches exactly to the solution code.
BUT when I click the eyeball to preview the code in the browser window, it causes all my treehouse tabs to hang. it doesn't look like I've created an infinite loop anywhere, but at this point, I'm not sure I'm doing anything right.
Any help is appreciated. Thanks!
var html = '';
var red;
var green;
var blue;
var rgbColor;
for (var i = 0; i < 10; i =+ 1) {
red = Math.floor(Math.random() * 256 );
green = Math.floor(Math.random() * 256 );
blue = Math.floor(Math.random() * 256 );
rgbColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
html += '<div style="background-color:' + rgbColor + '"></div>';
}
document.write(html);
lastly, I've run the downloaded solution code and it behaves the exact same way it's demo'd in the video.
Thanks!
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey there,
Just a quick glance, it looks like you have the incrementing symbol backward for the variable in the for loop. You have =+ when it should be +=.
Give that a go and see if that solves it.
:)
P.S. I also added JavaScript declaration to the Markdown for the code so syntax highlighting is correct. :)
alee2
5,435 Pointsalee2
5,435 Pointswell....that's not at all embarassing.? Thank you for finding what I couldn't after having stared at it for an hour.
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsYou're welcome. Don't worry... I've been there too. Lol.