Appaerntly there is something wrong with my code - help


This is my code:

var cities = ["Melbourne", "Amman", "Helsinki", "NYC", "Riyadh", "Shanghai", "Mumbai", "Virginia"];

for (var i = 0; i < cities.length; i++) {
console.log("I would like to visit " + cities[i]);

But i see nothing wrong with it but the following error pops up:

TypeError: console.log is not a function


Try putting a semi-colon after the bracket at the end of the for loop. And then change your variable name to "name" as per the directions. There are a few more details in the instructions that will stop your code from passing. It works fine, but won't pass. That is if were are talking about the same exercise. If not, you just needed the semi-colon.

var names = ["Melbourne", "Amman", "Helsinki", "NYC", "Riyadh", "Shanghai", "Mumbai", "Virginia"];

for (var i = 0; i < names.length; i++) {
console.log("I would like to visit " + cities[i]);


Aha thank you very much. I'm finally able to pass onto the next lesson.


excellent !

Keep on Hacking!


Also if it complains about console.log not being a function:

  1. Check if there are any statements that change the value of console.log by console.log = ...
  2. Refresh the page to reset console.log to its initial value.