JavaScript JavaScript Basics Introducing JavaScript The Console Challenge Answer

Cora Weiss
PRO
Cora Weiss
Pro 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
Pro 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,261 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