1

I'm on day four of teaching my self. I have saved as my practice document as a .js JavaScript file, and selected "JavaScript" in the language drop down menu, however in contrast to the way I am learning JavaScript on scrimba.com the only way my JavaScript code will run is if I surround all separate functions with <script> ... </script> and that seems more like HTML than JavaScript.

I have tried CTRL + SHIFT + J in chrome and paste my code, but I can't see any output. I have tried copying and pasting the saved JavaScript file that i made in Notepad++ with google chrome.

<script>
alert("javascript is running");
</script>

<script>
var myStr= "This is the start." + " This is the end.";
</script>
<script>
document.write(myStr);
</script>

I suspect my code should be cleaner than what I provided, with less karats, however at the moment my code pops up as plain text in all scenarios that don't include the <script> ... </script>

Zoe
  • 27,060
  • 21
  • 118
  • 148
frozenmonkey
  • 7
  • 1
  • 3
  • 2
    Possible duplicate of [How do I link a JavaScript file to a HTML file?](https://stackoverflow.com/questions/13739568/how-do-i-link-a-javascript-file-to-a-html-file) – pmkro Apr 10 '19 at 16:46
  • 1
    Your JavaScript needs to run in a browser; create an HTML file that contains a `` element & save it in the same directory as your .js file. Remove the ` – Alex K. Apr 10 '19 at 16:46

0 Answers0