I have this code:
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var txt = '{"name":"John", "city":"New York"}'
var obj = JSON.parse(txt);
document.getElementById("demo").innerHTML = obj.name;
</script>
</body>
</html>
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"}'
Thank you!
` tag ^^
– treyBake Oct 30 '18 at 09:14