JavaScript JavaScript Basics Hello, JavaScript! JavaScript Challenge Solution

Jason Williamson
Jason Williamson
6,426 Points

Self-destructing message solution not working

I have typed in the exact code as provided by the instructor and I am not getting any of the appropriate responses

Dane Parchment
Dane Parchment
Treehouse Moderator 10,307 Points

Can you please provide the code that you yourself have written? It's still possible you accidentally added or removed something that is causing issues.

1 Answer

Vaidehi S
Vaidehi S
4,278 Points

Hi,

I have the same code and when I click the preview it open the webpage with the h1 tag but the alerts and other functions are not working for me. Please see the below code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript Basics – Challenge</title> <link href="css/style.css" rel="stylesheet">
</head> <body> <main> <h1>Welcome to the Webpage!!</h1> </main> <script src="js/script.js"></script>
</body> </html>

alert("Warning! This message will self-destruct in"); alert("3..."); alert("2..."); alert("1..."); document.querySelector("h1").textContent = "🔥BOOM!🔥"; console.log("Message destroyed!");

Please let me know what is wrong with this. Thanks

Vaidehi S
Vaidehi S
4,278 Points

Message in the console.log is not displaying. I have saved the file as well.