I’m using Rails 4.2.3. I have this Javascript
for (i = 0; i < listItems.length; i++) {
if (listItems[i] === window.location.pathname)
return i
}
that I want to turn into coffee script. So I tried
if window.location.pathname in [listItems[i]] return i for i in [0...listItems.length]
but upon running this, I get the error “SyntaxError: [stdin]:77:3: unexpected if”. What is the right way to translate this JS?
Aucun commentaire:
Enregistrer un commentaire