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

Mariam Jabbar
Mariam Jabbar
675 Points

console.log("Begin program!");

I have included the app.js file into the html as I should but I keep getting an error message.

index.html
<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>JavaScript Basics</title>
  </head>
  <body>

  <script src="app.js"></script>

  </body>
</html>
app.js
console.log("Begin program!");

3 Answers

Laura Coronel
STAFF
Laura Coronel
Treehouse Teacher

Hi Mariam Jabbar 👋

The error message should usually give you a clue about what’s wrong in your code. In this case, I believe the challenge is expecting the exact text Begin program in the console.

Right now your code is printing Begin program! with an exclamation point, which makes it different from the expected output. Try removing the ! and see if that fixes the error.

Rarity Le'mons Bey
Rarity Le'mons Bey
765 Points

I'm experiencing the same issue that I've been triaging for 48hrs.

This is what I have on my console: index.html:

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>JavaScript Basics</title>
  </head>
  <body>
  </body>
  <script src="app.js"></script>
</html>
app.js:
console.log('Begin program')
alert('I am Programming!')
alert('Welcome to JavaScript Basics')
console.log('End program')

I'm unable to proceed to the next step because of this issue.

Laura Coronel
STAFF
Laura Coronel
Treehouse Teacher

Hi Rarity Le'mons Bey,

Thanks for sharing your code. I can see why the challenge is marking it as incorrect.

The issue isn't with your HTML file—it's in your app.js. The challenge only expects you to create a single alert:

alert('I am Programming!')

You currently have a second alert:

alert('Welcome to JavaScript Basics')

Since the challenge isn't expecting that additional code, it's marking your solution as incorrect even though the code itself runs without errors.

Try removing:

alert('Welcome to JavaScript Basics')

and then submit again. Your file should look like:

console.log('Begin program');
alert('I am Programming!');
console.log('End program');

Once you remove the extra alert, the challenge should pass.

Rarity Le'mons Bey
Rarity Le'mons Bey
765 Points

I couldn't believe this is the minor issue. I thought for some reason during the challenge tasks I needed to add alert ('Welcome to JavaScript Basics'). I wish I would have thought to reach out sooner but I wanted to triage it myself and do a search to debug the code but it didn't catch this error. Thanks.