Looping JavaScript Arrays
So I have a small question: What’s wrong with my code? I’m trying to obviously just loop through and print the contents of this array and I’m new to JavaScript but nothing really looks wrong to me? I pasted the errors I’ve received below.
var locations = [ "One", "Two", "Three"
];
function createArray() {
for (var i = 0; i < locations.length(); i++) { alert(locations[i] + "\n";); } }
12: Expected ']' at column 5, not column 1.];
20: Missing 'use strict' statement.for (var i = 0; i < locations.length(); i++)
20: Move 'var' declarations to the top of the function.for (var i = 0; i < locations.length(); i++)
20: Stopping. (83% scanned).for (var i = 0; i < locations.length(); i++)
Thanks for any assistance!













