On Feb 2, 2015, at 3:38 PM, Thomas Shinnick wrote:

> Whenever you see something you don't recognize, that just might be part of 
> Javascript you didn't know about, try checking with one of the Javascript 
> reference sites.  I'm sure there are a few opinions which is 'best', but I 
> just check the Mozilla site, such as searching for "mdn javascript foreach" 
> with Google which gets you to Array.prototype.forEach()
> But what you have cited seems to be missing a callback reference, like 
> 
> list.foreach( function(file){  
>   if file.ext = ext then {
>      console.log(item[i]
>   }
> });
> 
> Can you look at that "official answer" again?

Let's also not forget to capitalize "forEach" correctly; that we need 
parentheses around the conditional; that we want to compare, not assign; that 
there is no such JavaScript keyword as "then"; and that in the revised code, 
there is no variable "i":


list.forEach(function (file) {  
  if (file.ext == ext) {
    console.log(file);
  }
});


There's also no such thing as a "list" in JavaScript; it's called an "array". 
More here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/65331025-D7B8-4E62-BE3B-28C4B5BAA39C%40ryandesign.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to