Reputation: 19
So I found online javascript tutorials and I downloaded notepad++ to write my code. The problem is that I can't run it. I tried saving it as .html and then running it with mozilla but then I got the whole code written into the mozilla window.
I mean if the code is
var x = 5;
console.log(x);
I get this whole thing written there, not executed.
Upvotes: 0
Views: 4040
Reputation: 3039
Maybe you are not showing file extension in windows, and you think that you are saving it in "index.html" but you are saving as "index.html.txt" and mozilla opens it as a text file
Upvotes: 0
Reputation: 21575
JavaScript needs to be in a <script>
tag for a HTML file:
<script>
var x = 5;
console.log(x);
</script>
You can also define the JavaScript in a .js
file and reference it by doing:
<script src="myJSFile.js"></script>
In that case you don't need to place <script>
tags inside the .js
file.
Upvotes: 3