I have 3 html and javascript files… for example:
script1.html + script1.js
script2.html + script2.js
show.html + show.js
I’ve connected all .js in .html files:
<script type="text/javascript" src="script1.js"></script>
<script type="text/javascript" src="script2.js"></script>
<script type="text/javascript" src="show.js"></script>
script1.js:
global = [];
function addvalue1() {global.push("hey")}
script2.js:
function addvalue2() {global.push("hello")}
show.js:
function showvalue() {
console.log(global[0]);
console.log(global[1]);
}
addvalue1();
addvalue2()
showvalue();
In console it says:
undefined
undefined
What did I do wrong?