RE: Saving Notes to a JSON file: Day Six of "The Complete Node.js Developer Course"

You are viewing a single comment's thread from:

Saving Notes to a JSON file: Day Six of "The Complete Node.js Developer Course"

in javascript •  7 years ago 

Awesome share Matt! (or do you go by Matthew?)

var duplicateNotes = notes.filter((note) => note.title === title)

Your explanation of how it works is correct. Since notes contains a list of javascript object like

{
  title: 'Some String'
  body: 'whatever'
}

It basically is "filter"-ing out from your array of objects that matches those conditions... in this case "title".

The ((note)) part is arbitrary. You could have put apple and do the comparison like apple.title === title.

It is not related to the note variable you created initially in the addNote function. Hope that helps :)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks, that does help. I appreciate it.

I do go by Matthew.

I am not to up on JavaScript lambda but is this valid, as in no brackets around the param. I know C# only requires the brackets when more than one argument into the lambda.

var duplicateNotes = notes.filter(note => note.title === title)

As you can see, I am a clean code junkie lol The less characters while remaining readable is always better :)