How to put script in a separate file? : <p>I have this code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;p id="demo"&gt;&lt;/p&gt;
&lt;script&gt;
var txt = '{"name":"John", "city":"New York"}'
var obj = JSON.parse(txt);
document.getElementById("demo").innerHTML = obj.name;
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>How to put the script in another file named "myscript.js" and connect to html page?
I want to do that because i want to link the script to multiple html pages and sometimes i need to change var txt = '{"name":"John", "city":"New York"}'</p>

<p>Thank you!</p>
