samedi 5 décembre 2015

Check if array key equals certain value JavaScript

I have this array:

var arr = [ ['First', 'lorem ipsum'], ['Second', 'dolor sit amet'], ];

and I want if arr[0] equals First do action 1, else do action 2.

I used if(arr[0] == 'First') { but I get Uncaught SyntaxError: Unexpected token [.

How should I do this?

Aucun commentaire:

Enregistrer un commentaire