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 trial

JavaScript JavaScript Basics (Retired) Working With Numbers The Random Challenge Solution

None of my Javascript code is showing up in my preview page. Can someone help me please?! I am saving my work.

document.write('This will not show up in my preview page');

Jesse Zelaya
Jesse Zelaya
13,599 Points

Could you provide all of your code?

What do you mean? shouldn't that show up? or does it have to be connected to an html file?

document.write(shit ain't workin);

-> random.js

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/main.css">
  <title>JavaScript Basics</title>
 </head>
<body>
  <div class="container">
  <h1>Random Number Generator</h1>
   <script src="random.js"></script> 
  </div>
</body>
</html>

-> index.html

Jason Berteotti
Jason Berteotti
12,352 Points

We cannot see your code to help you. Snapshot your workspace and share the link so we can review it.

1 Answer

Have you saved both the html and the js file? Otherwise it won't show.

as far as the code goes:

<body>
  <div class="container">
    <h1>Random Number Generator</h1>
  </div>
  <script src="random.js"></script>  <-- put this just before the closing of the body and not inside the div
</body>
document.write("fun stuff"); <-- make sure the stuff you want to write is in quotes " " or ' '