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) Introducing JavaScript The Console Challenge Answer

Cora Weiss
PLUS
Cora Weiss
Courses Plus Student 1,271 Points

my code is identical to the code demonstrated in the debugging challenge, but the alerts are still not showing up.

alerts not showing up in the preview

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>What's wrong with this script?</title> </head> <body> <div class="container"> <h1>Can you get the JavaScript to work?</h1> <script src="scripts.js"></script> </div> </body> </html>

console.log("start program"); alert("Help me fix this program!"); alert("Can you get this message to appear?"); document.write("<h2>My first JavaScript program</h2>"); document.write("<p>I'm practicing 'debugging'.</p>"); console.log("end program");

Jack Dinker
Jack Dinker
Courses Plus Student 1,374 Points

Your browser is caching their code and not reloading the changes you've made even after saving. You would have to clear your cache every time. In order to make this easy, if you are using Chrome, download Cache Killer to have it clear your cache every time you open a page.

https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap?hl=en

3 Answers

Jeff Lemay
Jeff Lemay
14,268 Points

This code works for me. Do you have script tags wrapped around it?

<script>
console.log("start program"); alert("Help me fix this program!"); alert("Can you get this message to appear?"); document.write("My first JavaScript program"); document.write("I'm practicing 'debugging'."); console.log("end program");
</script>
Jae Min Kweon
Jae Min Kweon
4,695 Points

Try using ctrl+r or f5 after you load up the preview page.

Just press f5 and relaunch preview