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 Write Another Program

Ali Sh
Ali Sh
2,026 Points

How can i do this question?

how to enter script tags in the index.html?

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script scr="script.js")></script>
alert("warning");
  <script>
</body>
</html>

2 Answers

tomd
tomd
16,701 Points

You don't need a source attribute if you're writing javascript inside script tags. You also have two opening and closing script tags, that you don't need.

Try this

<script>
    alert('warning')
</script>

Any 'code' must be either between a starting <script> and ending </script> tag OR in the file referenced in the src (Note src, not scr - abbreviation of SouRCe) part of the script tags. You can't do both at the same time though.

GOOD

<script>
  my code here
</script>

GOOD

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

BAD

<script src="mycodefile.js">
  More code here.
</script>