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 Hello, JavaScript! Write JavaScript Statements

challenge task 2

The error message: Bummer: Make sure you print 'Begin program' in the console

What wrong with my code?

index.html
<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>JavaScript Basics</title>
  </head>
  <body>
    <h1>🔥BOOM!🔥</h1>
    <script src="app.js"></script>
  </body>
</html>
app.js
alert("Warning! This message will self-destruct in");
alert("3"); 
alert("2"); 
alert("1"); 
document.querySelector('h1').textContent = '🔥BOOM!🔥';
console.log("Message destroyed!");
console.log("Begin program");

1 Answer

Steven Parker
Steven Parker
231,236 Points

Your program is printing many things not asked for by the instructions, and it also requires user interaction (several times) before it accomplishes the objective. Remove all the extra alerting and logging to pass task 2.

For best results with the challenges, always do only what the instructions ask for to avoid confusing the evaluator.
Experiment as you like in the workspace exercises.

Thank you. I found my mistake. The instruction said that I should add my code to the previous task. I didn't clear understand that I don't need clear the previous code, but should use // for comment previous code.

Steven Parker
Steven Parker
231,236 Points

Anna Bazileeva — You won't ever need to copy code from the workspace projects into challenges. They may have similar objectives to the exercises, but they won't ever be exactly the same or require any preliminary code other than what they give you. When they say "previous task", they are only talking about the tasks of the challenge itself (for example, this one has 4).

Glad I could help. You can mark a question solved by choosing a "best answer".
And happy coding!