Skip to content
Advertisement

why isnt javascript ‘For’ statement working in array?

i have a script that creates an array of words from a sencence and then capitalises each letter i am getting sintax errors whenever i run the script. Here is all of the JavaScript that is related to the input and output boxes.

JavaScript

the error is for the i in addressArray[i] and the townArray[i] i feel like it is stupidly simple but im stumped.

Advertisement

Answer

var addressArray[i] = isn’t valid syntax.

Drop the var, as you’re not declaring a variable:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement