0
Can someone please explain this?
// above is function(){ // var names=[ ] // } function array(){ var i=0 var j=0 var k=0 var l=0 var m=0 window.names[i] = document.getElementById("subject").value; i++; document.getElementById("subject").value = ""; It says error cant set property '0' of undefined. I cant tell where the error is. https://code.sololearn.com/WgyjaJ3BwMOr/?ref=app https://code.sololearn.com/WgyjaJ3BwMOr/?ref=app https://code.sololearn.com/WgyjaJ3BwMOr/?ref=app
5 Answers
+ 2
That's because window.names is not defined. By the way, a lot of semicolons in the code are missing.
+ 2
You should be careful, because variables defined locally in a function won't be available outside of it.
+ 1
It doesnt matter whether i use semicolon or not in javascript. But i have no idea why it doesnt work where as i used window.names to call variable names inside another function.
+ 1
Yes, but the problem is that you declared the variable inside a function. You should do it outside it. Same with verbs, nouns and the rest of it.
0
Thx very much but ive done the project!