JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops For Loops

Samuel Villa-Smith
Samuel Villa-Smith
Full Stack JavaScript Techdegree Student 1,431 Points

Unable to Run Code

The Preview is stuck in a white space loading screen. My code is exactly the same as in the video. What's wrong? Also my script.js file is in the JS folder...

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Circles</title> <link rel="stylesheet" href="css/styles.css"> </head> <body id="color"> <script src="js/script.js"></script> </body> </html>

var html = ''; for (var i = 1; i <= 10; i += 1) { html += '<div>' + i + '</div>'; } document.write(html);

Steven Parker
Steven Parker
182,307 Points

This code seems to work OK, maybe there's something wrong elsewhere in the build environment.
To enable more thorough analysis, make a snapshot of your workspace and post the link to it here.

1 Answer

amirmhossein
amirmhossein
3,336 Points

Double check your var html , i think the problem is quote marks . To give it a empty string try this var html = ' ';

Steven Parker
Steven Parker
182,307 Points

The original code correctly assigns an empty string. This snippet assigns a space.