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 Your First JavaScript Program

James George
James George
476 Points

Add a code in script - where do I place the code in front for the web page. <script>

I found script but when i put the code in, it says erro-

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
</body>

  <script> content= 'Welcome to my site'</script>
// Write your code here.

</script>

</html>

2 Answers

Cory Harkins
Cory Harkins
16,500 Points

Edited: didn't actually look at the challenge in question

There are multiple issues with your file, first you have an extra closing </script> tag. Second content = ' Welcome to my site ' is wrongly defined, it should be var content = 'Welcome to my site' Third there are plenty of ways to solve this issue in reality, however, I believe for this challenge they are wanting a document dot method those methods can be found here (https://developer.mozilla.org/en-US/docs/Web/API/Document/) on the left hand side.

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body>

<script> var content= 'Welcome to my site'; </script>

</body> </html>