0

I created an Array:

var book = {title: "Ways to Go", pages: 280, bookMark1:"Page 20"};

and now I want to loop over the Array and log all properties:

function me {
i;
for ( i = 0; i < book.length ; i++ ) { 
console.log(i);
}
};

It logs "SyntaxError" but I don't understand where it is

Thanks

KR29
  • 393
  • 1
  • 4
  • 19
  • 3
    Lot of errors are there.. Are you new to javascript? If so, I would suggest you to read [this](https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics). – Rajaprabhu Aravindasamy Jul 25 '16 at 17:42
  • try to add befor the for "let i" instead of "i". – Stav Alfi Jul 25 '16 at 17:43
  • 6
    First off, that's not an array – j08691 Jul 25 '16 at 17:43
  • This is valid JavaScript: `var book = {title: "Ways to Go", pages: 280, bookMark1:"Page 20"}; function me() { for (var i = 0; i < book.length ; i++ ) { console.log(i); } }` Note the parentheses after a function. What is the meaning of `book.length`? What would be a better name for `i`? – user2609980 Jul 25 '16 at 17:47
  • that's an object. Array uses square brackets like so ['itemOne', 'itemTwo'] – nuway Jul 25 '16 at 17:48
  • book.length means each items, also property in object – Giorgi Giorgi Jul 25 '16 at 17:49

0 Answers0